ensure we can delete invalid read-only items

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
This commit is contained in:
Matthieu Gallien 2025-02-21 13:47:00 +01:00
parent 0919bb94cf
commit 240e7fa6b6
No known key found for this signature in database
GPG Key ID: 7D0F74F05C22F553

View File

@ -1736,7 +1736,16 @@ void Folder::slotNeedToRemoveRemnantsReadOnlyFolders(const QList<SyncFileItemPtr
setSyncPaused(true);
for(const auto &oneFolder : folders) {
FileSystem::removeRecursively(localPath + oneFolder->_file);
#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
const auto fileInfo = QFileInfo{localPath + oneFolder->_file};
const auto parentFolderPath = fileInfo.dir().absolutePath();
const auto parentPermissionsHandler = FileSystem::FilePermissionsRestore{parentFolderPath, FileSystem::FolderPermissions::ReadWrite};
#endif
if (oneFolder->_type == ItemType::ItemTypeDirectory) {
FileSystem::removeRecursively(localPath + oneFolder->_file);
} else {
FileSystem::remove(localPath + oneFolder->_file);
}
}
callback(true);
setSyncPaused(false);