enable users to delete unexpected new folders inside a read-only folder

let unexpected new folders in read-only folders be read-write

would be done for folders that are inside a read-only folder and cannot
be uploaded because the parent folder is realy read-only

most probably those folders should never have been there

in case they would be read-only, users cannot delete them, in such
situation, letting them be read-write again should really help

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
This commit is contained in:
Matthieu Gallien 2024-08-22 14:50:26 +02:00 committed by Matthieu Gallien
parent 96d4062425
commit 3e397e664d

View file

@ -1828,6 +1828,9 @@ bool ProcessDirectoryJob::checkPermissions(const OCC::SyncFileItemPtr &item)
qCWarning(lcDisco) << "checkForPermission: ERROR" << item->_file;
item->_instruction = CSYNC_INSTRUCTION_ERROR;
item->_errorString = tr("Not allowed because you don't have permission to add subfolders to that folder");
const auto localPath = QString{_discoveryData->_localDir + item->_file};
qCWarning(lcDisco) << "unexpected new folder in a read-only folder will be made read-write" << localPath;
FileSystem::setFolderPermissions(localPath, FileSystem::FolderPermissions::ReadWrite);
return false;
} else if (!item->isDirectory() && !perms.hasPermission(RemotePermissions::CanAddFile)) {
qCWarning(lcDisco) << "checkForPermission: ERROR" << item->_file;
@ -2029,6 +2032,9 @@ int ProcessDirectoryJob::processSubJobs(int nbJobs)
qCWarning(lcDisco) << "checkForPermission: ERROR" << _dirItem->_file;
_dirItem->_instruction = CSYNC_INSTRUCTION_ERROR;
_dirItem->_errorString = tr("Not allowed because you don't have permission to add subfolders to that folder");
const auto localPath = QString{_discoveryData->_localDir + _dirItem->_file};
qCWarning(lcDisco) << "unexpected new folder in a read-only folder will be made read-write" << localPath;
FileSystem::setFolderPermissions(localPath, FileSystem::FolderPermissions::ReadWrite);
}
_dirItem->_direction = _dirItem->_direction == SyncFileItem::Up ? SyncFileItem::Down : SyncFileItem::Up;