Skip to content

Offer to delete the local folder when removing an account or sync connection - #12688

Open
Eiji-Kondo wants to merge 1 commit into
owncloud:masterfrom
Eiji-Kondo:feature/delete-local-folder-on-account-removal
Open

Eiji-Kondo wants to merge 1 commit into
owncloud:masterfrom
Eiji-Kondo:feature/delete-local-folder-on-account-removal

Conversation

@Eiji-Kondo

Copy link
Copy Markdown

Summary

Removing an account or a folder sync connection kept the local folder on disk
without offering any choice. Because the account wizard then re-uses
~/ownCloud and appends a number whenever that path already exists, every
remove-and-re-add cycle created a new folder (ownCloud (2), ownCloud (3),
…).

This adds an opt-in checkbox to both removal confirmations:

  • Confirm Account Removal (AccountViewController::onDeleteAccount())
  • Confirm Folder Sync Connection Removal (AccountFoldersController::onRemoveSync())

The checkbox ("Also delete the local folder …") is unchecked by default, so the
existing safe behaviour is preserved. It is only shown when the folder actually
exists on disk.

When enabled, the folder is removed through the new
FolderMan::removeLocalFolder() helper, which:

  • prefers QFile::moveToTrash() so the removal stays recoverable,
  • falls back to FileSystem::removeRecursively() only when trashing is not
    supported (e.g. some network or FAT filesystems),
  • refuses to touch the user's home directory or a filesystem root.

Related issue

Fixes #12687

How to test

  1. Add an account with default settings (~/ownCloud).
  2. Remove the account. The dialog now shows the new checkbox; leave it off and
    confirm — the folder must remain on disk.
  3. Re-add the account and remove it again, this time ticking the checkbox. The
    folder should disappear (to the trash where supported).
  4. Repeat the same for a folder sync connection ("Remove sync" in the Folders
    view).

Automated tests

TestFolderMan::testRemoveLocalFolder covers the helper directly: it removes a
populated temp folder, treats a missing path as a no-op, and asserts that the
home directory and / are never deleted.

Totals: 6 passed, 0 failed, 0 skipped, 0 blacklisted

The changes build cleanly against Qt 6.8 (owncloudGui and FolderManTest),
and a changelog item is included.


This pull request was created by an AI agent (OpenHands) on behalf of a user.

@Eiji-Kondo
Eiji-Kondo requested a review from a team as a code owner November 11, 2026 01:25
@CLAassistant

CLAassistant commented Nov 11, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

…c connection

Removing an account or a folder sync connection left the local folder on disk
without any choice. On the next setup the client found the folder still present
and created a numbered duplicate such as "ownCloud (2)", "ownCloud (3)".

Add an opt-in checkbox to both removal confirmations. It defaults to off, so
the previous safe behaviour is unchanged. When enabled the folder is moved to
the OS trash (QFile::moveToTrash), falling back to a recursive delete only when
trashing is unsupported. FolderMan::removeLocalFolder() refuses to touch the
user's home directory or a filesystem root.
@Eiji-Kondo
Eiji-Kondo force-pushed the feature/delete-local-folder-on-account-removal branch from 8806c94 to b44ecac Compare November 11, 2026 01:31
@modSpike

Copy link
Copy Markdown
Contributor

I cannot yet comment on the need for this functionality, or if this is how we want to implement such a thing, but FolderMan is not the right place for the removeLocalFolder function. Refactoring the class to refine encapsulation is ongoing and the goal is that FolderMan should only deal with Folder (as in the class) related operations. This is a generic file system operation that is invoked after the Folder instance has been destroyed (note: check that to be 100% certain it's the case) so imo it does not belong in FolderMan.

We have a FolderManagementUtils for handling static folder path related operations - I'd prefer to see the remove operation in there.

Additionally the routine to remove local folders when deleting an account is insufficient because it does not consider that the user may have added syncs with local folders outside of the default sync root (this is always possible on mac and linux when adding a new sync manually -> aka selective sync).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Account removal silently keeps the local sync folder, so re-adding creates ownCloud (2), (3), …

3 participants