Return bool from FileSystem::setFileReadOnlyWeak depending on whether permission change was actually made or not

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2023-07-07 19:14:09 +08:00
parent 32145342c8
commit 9811d35a96
2 changed files with 4 additions and 4 deletions

View File

@ -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,

View File

@ -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