Skip to content

CLI account setup only supports one sync folder per invocation #9966

@Unbrot

Description

@Unbrot

Problem

The command-line account setup feature (--userid, --apppassword, --serverurl, --localdirpath, --remotedirpath) currently has two limitations that make it impossible to configure more than one sync folder:

1. Repeated --localdirpath / --remotedirpath arguments are silently ignored

In src/gui/accountsetupcommandlinemanager.cpp, each argument is stored in a single QString member variable (_localDirPath, _remoteDirPath). Passing the same flag multiple times simply overwrites the previous value — only the last pair survives into the setup job.

2. A second invocation is rejected because the account already exists

src/gui/accountsetupfromcommandlinejob.cpp checks whether the account (userid@hostname) is already registered and exits with code 1 if so. This means there is no way to add a second sync folder to an already-configured account via the CLI — not in a single invocation, and not by running the app a second time.

Expected behaviour

It should be possible to configure multiple sync folders for the same account in one CLI invocation, e.g.:

nextcloud \
  --userid alice \
  --apppassword secret \
  --serverurl https://cloud.example.com \
  --localdirpath ~/Documents --remotedirpath /Documents \
  --localdirpath ~/Photos   --remotedirpath /Photos

Suggested fix

  1. Change _localDirPath and _remoteDirPath in AccountSetupCommandLineManager from QString to QList<QString>, accumulating each flag value instead of overwriting.
  2. In AccountSetupFromCommandLineJob, when the account already exists, skip account creation and proceed directly to folder setup instead of aborting.
  3. Iterate over all requested folder pairs and call setupLocalSyncFolder for each one.

A working implementation is available as a pull request.

Affected files

  • src/gui/accountsetupcommandlinemanager.h / .cpp
  • src/gui/accountsetupfromcommandlinejob.h / .cpp

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions