feat(cli): support multiple sync folders in command-line account setup#9967
feat(cli): support multiple sync folders in command-line account setup#9967Unbrot wants to merge 2 commits into
Conversation
Allow repeated --localdirpath/--remotedirpath pairs so that more than one folder can be configured in a single invocation. Previously only the last value of each flag was kept; now all pairs are accumulated and set up in order. Also allow the CLI to add folders to an account that already exists instead of aborting with an error, making it possible to provision additional sync folders without re-creating the account. Closes #1 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Btw. I compiled the changes and tested them on linux fedora / kde plasma wayland - It worked. We need it for Autoprovisioning nc desktop in our company. Using the already existent logic may be a better solution, than to modify the config itself from outside, as i saw in some descriptions. |
When the same --localdirpath/--remotedirpath pair is passed for a folder that is already registered, silently skip it instead of adding a duplicate entry under the Multifolders settings group. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The test showed a small glitch: If the same remote and local folder was specified with another run, than it got appended as multifolder, which makes no sense at all. should be fixed now. |
|
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
Fixes #9966
Summary
--localdirpath/--remotedirpathpairs so that multiple sync folders can be configured in a single CLI invocationProblem
Previously
_localDirPathand_remoteDirPathwere singleQStringmembers, so repeated flags silently overwrote each other. Additionally, a second invocation for the same account was rejected outright, making it impossible to add folders to an existing account via CLI.During testing of the "repeated invocation for existing account" case, running the same command twice produced duplicate entries under the
Multifolderssettings group (indices 3 and 4 alongside the correctFolders\2entry). This happened because the local directory is empty right after CLI setup (the sync journal is only written when the sync engine first runs), so the existing non-empty-directory guard did not catch the re-invocation. The result was two sync engines running against the same local and remote path simultaneously — causing redundant work and potential conflicts with no benefit.Changes
AccountSetupCommandLineManager: replaced_localDirPath/_remoteDirPathwithQList<QString>accumulators; pairs are zipped and passed to the jobAccountSetupFromCommandLineJob: constructor now acceptsQList<QPair<QString,QString>>; existing accounts are reused rather than rejected;setupLocalSyncFoldersiterates over all pairs; newly-created accounts are rolled back on failure but existing accounts are left intactAccountSetupFromCommandLineJob::setupLocalSyncFolders: before callingaddFolder, check whether any existing folder already has the samecleanPathandremotePath; if so, log and skip — making the command idempotentTest results
Single folder (
--localdirpath ~/nc_test/1 --remotedirpath /test/f1): folder appears in config asFolders\0, exit 0. ✅Multiple folders in one invocation (
--localdirpath ~/nc_test/1 --remotedirpath /test/f1 --localdirpath ~/nc_test/2 --remotedirpath /test/f2): both folders appear in config (Folders\0,Folders\1), files synced correctly on both paths. ✅Repeated invocation for existing account — new folder (
--localdirpath ~/nc_test/3 --remotedirpath /test/f3on an account already having f1/f2): folder added asFolders\2, account not deleted, exit 0. ✅Repeated invocation for existing account — already-configured folder (same command run a second time): duplicate skipped with log message
Folder … is already configured. Skipping., config unchanged, exit 0. ✅Non-empty local folder: rejected with error before any account or folder is created. ✅
Missing
--remotedirpath: defaults to/. ✅🤖 Generated with Claude Code