Skip to content

Commit

Permalink
Merge pull request #7081 from nextcloud/backport/7079/stable-3.13
Browse files Browse the repository at this point in the history
[stable-3.13] add missing exception handling
  • Loading branch information
mgallien authored Sep 9, 2024
2 parents d84ee83 + a1a56ed commit d0a0172
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/libsync/filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down

0 comments on commit d0a0172

Please sign in to comment.