fix(delete): fix move to trash when parent folder is read-only

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
This commit is contained in:
Matthieu Gallien 2025-05-15 12:30:25 +02:00
parent 584c81321f
commit db58703fc0

View File

@ -101,6 +101,9 @@ void PropagateLocalRemove::start()
if (_moveToTrash && propagator()->syncOptions()._vfs->mode() != OCC::Vfs::WindowsCfApi) {
const auto fileInfo = QFileInfo{filename};
if (FileSystem::fileExists(filename, fileInfo)) {
const auto parentFolderPath = fileInfo.dir().absolutePath();
const auto parentPermissionsHandler = FileSystem::FilePermissionsRestore{parentFolderPath, FileSystem::FolderPermissions::ReadWrite};
if (!FileSystem::moveToTrash(filename, &removeError)) {
qCWarning(lcPropagateLocalRemove()) << "move to trash failed" << filename << removeError;
done(SyncFileItem::NormalError, tr("Temporary error when removing local item removed from server."), ErrorCategory::GenericError);