Merge pull request #7079 from nextcloud/bugfix/handleExceptionsFromFileSystemOps

add missing exception handling
This commit is contained in:
Matthieu Gallien 2024-09-06 16:46:12 +02:00 committed by GitHub
commit 2a987e9068
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -484,11 +484,15 @@ bool FileSystem::isFolderReadOnly(const std::filesystem::path &path) noexcept
FileSystem::FilePermissionsRestore::FilePermissionsRestore(const QString &path, FolderPermissions temporaryPermissions)
: _path(path)
{
const auto stdStrPath = _path.toStdWString();
_initialPermissions = FileSystem::isFolderReadOnly(stdStrPath) ? OCC::FileSystem::FolderPermissions::ReadOnly : OCC::FileSystem::FolderPermissions::ReadWrite;
if (_initialPermissions != temporaryPermissions) {
_rollbackNeeded = true;
FileSystem::setFolderPermissions(_path, temporaryPermissions);
try {
const auto stdStrPath = _path.toStdWString();
_initialPermissions = FileSystem::isFolderReadOnly(stdStrPath) ? OCC::FileSystem::FolderPermissions::ReadOnly : OCC::FileSystem::FolderPermissions::ReadWrite;
if (_initialPermissions != temporaryPermissions) {
_rollbackNeeded = true;
FileSystem::setFolderPermissions(_path, temporaryPermissions);
}
} catch (const std::filesystem::filesystem_error &e) {
qCWarning(lcFileSystem()) << "exception when modifying folder permissions" << e.what() << e.path1().c_str() << e.path2().c_str();
}
}