Skip to content

Commit

Permalink
Ensure we are re-adding same permissions as removed
Browse files Browse the repository at this point in the history
Signed-off-by: Claudio Cambra <[email protected]>
  • Loading branch information
claucambra authored and backportbot[bot] committed Jun 28, 2024
1 parent 324054c commit 82197c7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/libsync/filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,11 @@ bool FileSystem::getInode(const QString &filename, quint64 *inode)
bool FileSystem::setFolderPermissions(const QString &path,
FileSystem::FolderPermissions permissions) noexcept
{
static constexpr auto writePerms = std::filesystem::perms::owner_write | std::filesystem::perms::group_write | std::filesystem::perms::others_write;
try {
switch (permissions) {
case OCC::FileSystem::FolderPermissions::ReadOnly:
std::filesystem::permissions(path.toStdWString(), std::filesystem::perms::owner_write | std::filesystem::perms::group_write | std::filesystem::perms::others_write, std::filesystem::perm_options::remove);
std::filesystem::permissions(path.toStdWString(), writePerms, std::filesystem::perm_options::remove);
break;
case OCC::FileSystem::FolderPermissions::ReadWrite:
break;
Expand Down Expand Up @@ -457,7 +458,7 @@ bool FileSystem::setFolderPermissions(const QString &path,
case OCC::FileSystem::FolderPermissions::ReadOnly:
break;
case OCC::FileSystem::FolderPermissions::ReadWrite:
std::filesystem::permissions(path.toStdWString(), std::filesystem::perms::owner_write, std::filesystem::perm_options::add);
std::filesystem::permissions(path.toStdWString(), writePerms, std::filesystem::perm_options::add);
break;
}
}
Expand Down

0 comments on commit 82197c7

Please sign in to comment.