Do not re-generate standard string path twice
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Wed, 26 Jun 2024 09:03:03 +0000 (17:03 +0800)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Fri, 28 Jun 2024 09:21:39 +0000 (09:21 +0000)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/libsync/filesystem.cpp

index 1d56cbdd83653ef7e3cc547a4255f77bd8248476..238c83eb41555e878178d6085db53ab059804dee 100644 (file)
@@ -319,10 +319,11 @@ 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(), writePerms, std::filesystem::perm_options::remove);
+            std::filesystem::permissions(stdStrPath, writePerms, std::filesystem::perm_options::remove);
             break;
         case OCC::FileSystem::FolderPermissions::ReadWrite:
             break;
@@ -458,7 +459,7 @@ bool FileSystem::setFolderPermissions(const QString &path,
         case OCC::FileSystem::FolderPermissions::ReadOnly:
             break;
         case OCC::FileSystem::FolderPermissions::ReadWrite:
-            std::filesystem::permissions(path.toStdWString(), writePerms, std::filesystem::perm_options::add);
+            std::filesystem::permissions(stdStrPath, writePerms, std::filesystem::perm_options::add);
             break;
         }
     }