Skip to content

Commit

Permalink
Merge pull request #6853 from nextcloud/backport/6839/stable-3.13
Browse files Browse the repository at this point in the history
[stable-3.13] Bugfix/rw folders broken
  • Loading branch information
claucambra authored Jun 28, 2024
2 parents 324054c + 41d9a12 commit 37dfede
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/libsync/filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,17 +318,17 @@ 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;
const auto stdStrPath = path.toStdWString();
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(stdStrPath, writePerms, std::filesystem::perm_options::remove);
break;
case OCC::FileSystem::FolderPermissions::ReadWrite:
break;
}
}
catch (const std::filesystem::filesystem_error &e)
{
} catch (const std::filesystem::filesystem_error &e) {
qCWarning(lcFileSystem()) << "exception when modifying folder permissions" << e.what() << e.path1().c_str() << e.path2().c_str();
return false;
}
Expand Down Expand Up @@ -451,22 +451,18 @@ bool FileSystem::setFolderPermissions(const QString &path,
}
#endif

#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_15
try {
switch (permissions) {
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(stdStrPath, writePerms, std::filesystem::perm_options::add);
break;
}
}
catch (const std::filesystem::filesystem_error &e)
{
} catch (const std::filesystem::filesystem_error &e) {
qCWarning(lcFileSystem()) << "exception when modifying folder permissions" << e.what() << e.path1().c_str() << e.path2().c_str();
return false;
}
#endif

return true;
}
Expand Down

0 comments on commit 37dfede

Please sign in to comment.