mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-22 04:55:48 +03:00
let FileSystem::removeRecursively be able to delete read-only folders
Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
This commit is contained in:
parent
5b8144f806
commit
27189bf4b1
1 changed files with 12 additions and 0 deletions
|
@ -273,6 +273,12 @@ bool FileSystem::removeRecursively(const QString &path, const std::function<void
|
|||
removeOk = removeRecursively(path + QLatin1Char('/') + di.fileName(), onDeleted, errors); // recursive
|
||||
} else {
|
||||
QString removeError;
|
||||
|
||||
#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 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<void
|
|||
allRemoved = false;
|
||||
}
|
||||
if (allRemoved) {
|
||||
#if !defined(Q_OS_MACOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 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)
|
||||
|
|
Loading…
Reference in a new issue