Repository navigation
Offer to delete the local folder when removing an account or sync connection - #12688
Eiji-Kondo wants to merge 1 commit into
Conversation
…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.
8806c94 to
b44ecac
Compare
|
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). |
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
~/ownCloudand appends a number whenever that path already exists, everyremove-and-re-add cycle created a new folder (
ownCloud (2),ownCloud (3),…).
This adds an opt-in checkbox to both removal confirmations:
AccountViewController::onDeleteAccount())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:QFile::moveToTrash()so the removal stays recoverable,FileSystem::removeRecursively()only when trashing is notsupported (e.g. some network or FAT filesystems),
Related issue
Fixes #12687
How to test
~/ownCloud).confirm — the folder must remain on disk.
folder should disappear (to the trash where supported).
view).
Automated tests
TestFolderMan::testRemoveLocalFoldercovers the helper directly: it removes apopulated temp folder, treats a missing path as a no-op, and asserts that the
home directory and
/are never deleted.The changes build cleanly against Qt 6.8 (
owncloudGuiandFolderManTest),and a changelog item is included.
This pull request was created by an AI agent (OpenHands) on behalf of a user.