From 9811d35a96c1815674e1deb9e44deed5baafd2ed Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Fri, 7 Jul 2023 19:14:09 +0800 Subject: [PATCH] Return bool from FileSystem::setFileReadOnlyWeak depending on whether permission change was actually made or not Signed-off-by: Claudio Cambra --- src/common/filesystembase.cpp | 6 +++--- src/common/filesystembase.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common/filesystembase.cpp b/src/common/filesystembase.cpp index 89c6426921..ef9ba1efd6 100644 --- a/src/common/filesystembase.cpp +++ b/src/common/filesystembase.cpp @@ -114,17 +114,17 @@ void FileSystem::setFolderMinimumPermissions(const QString &filename) #endif } - -void FileSystem::setFileReadOnlyWeak(const QString &filename, bool readonly) +bool FileSystem::setFileReadOnlyWeak(const QString &filename, bool readonly) { QFile file(filename); QFile::Permissions permissions = file.permissions(); if (!readonly && (permissions & QFile::WriteOwner)) { - return; // already writable enough + return false; // already writable enough } setFileReadOnly(filename, readonly); + return true; } bool FileSystem::rename(const QString &originFileName, diff --git a/src/common/filesystembase.h b/src/common/filesystembase.h index bc0b592c23..fd0572804d 100644 --- a/src/common/filesystembase.h +++ b/src/common/filesystembase.h @@ -65,7 +65,7 @@ namespace FileSystem { * This means that it will preserve explicitly set rw-r--r-- permissions even * when the umask is 0002. (setFileReadOnly() would adjust to rw-rw-r--) */ - void OCSYNC_EXPORT setFileReadOnlyWeak(const QString &filename, bool readonly); + bool OCSYNC_EXPORT setFileReadOnlyWeak(const QString &filename, bool readonly); /** * @brief Try to set permissions so that other users on the local machine can not