nextcloud / nextcloud/server

Add option for `files_external:import` to overwrite existing mounts (with the same `mount_id`)

Open
#35,786 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

0. Needs triage enhancement feature: external storage feature: occ
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

How to use GitHub
  • Please use the 👍 reaction to show that you are interested into the same feature.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

The Problem

I'm running a CI/CD pipeline for a NextCloud server. I have some external mounts defined as JSON files to keep them under version control. I'd like to automatically re-mount these external mounts again on successive deployments with the same mount_id so that all users the mounts are shared to see the updates.

The JSON files have a specified mount_id, and importing with the --dry option shows that this mount_id is indeed read correctly, however if these mount_ids are already in use, it imports them as new mounts. As much as I've looked there is no easy way to overwrite existing mounts on import, without truncating the database table, which seems a bit hacky.

Possible Solutions

Perhaps the files_external:import should offer a --force option that overwrites an existing mount if it exists?

Workaround

The workaround I'm currently using is first checking if the mounts exist, and if they do, instead of importing, I call :option and :config for all the fields. This however is incomplete as some things cannot be changed, such as the mount point, the authentication method and the type of mount (SMB, Dav, etc...)

Context

Using NextCloud 25.0.1 and MariaDB database. I'm persisting the database upon successive deployments, but I overwrite certain configurations on each deployment.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the files_external:import command and its external-mount import path. Reproduce the JSON import with an existing mount_id, then define done as an option that replaces the existing mount rather than creating a duplicate, including the fields the current workaround cannot change.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.