From 27189bf4b14a82c10fba0409e795ff7482a67b13 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Mon, 2 Sep 2024 13:53:11 +0200 Subject: [PATCH] let FileSystem::removeRecursively be able to delete read-only folders Signed-off-by: Matthieu Gallien --- src/libsync/filesystem.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libsync/filesystem.cpp b/src/libsync/filesystem.cpp index c05b297954..7ff29ca4c1 100644 --- a/src/libsync/filesystem.cpp +++ b/src/libsync/filesystem.cpp @@ -273,6 +273,12 @@ bool FileSystem::removeRecursively(const QString &path, const std::function= MAC_OS_X_VERSION_10_15 + const auto fileInfo = QFileInfo{di.filePath()}; + const auto parentFolderPath = fileInfo.dir().absolutePath(); + const auto parentPermissionsHandler = FileSystem::FilePermissionsRestore{parentFolderPath, FileSystem::FolderPermissions::ReadWrite}; +#endif removeOk = FileSystem::remove(di.filePath(), &removeError); if (removeOk) { if (onDeleted) @@ -289,6 +295,12 @@ bool FileSystem::removeRecursively(const QString &path, const std::function= MAC_OS_X_VERSION_10_15 + const auto fileInfo = QFileInfo{path}; + const auto parentFolderPath = fileInfo.dir().absolutePath(); + const auto parentPermissionsHandler = FileSystem::FilePermissionsRestore{parentFolderPath, FileSystem::FolderPermissions::ReadWrite}; + FileSystem::setFolderPermissions(path, FileSystem::FolderPermissions::ReadWrite); +#endif allRemoved = QDir().rmdir(path); if (allRemoved) { if (onDeleted)