mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-27 09:30:13 +03:00
Permissions: Keep more user permissions
t4.pl discovered that it'd needlessly override permissions sometimes
This commit is contained in:
parent
10db6cee6c
commit
6cf5fc7f7d
4 changed files with 27 additions and 3 deletions
|
@ -143,6 +143,19 @@ void FileSystem::setFileReadOnly(const QString& filename, bool readonly)
|
|||
file.setPermissions(permissions);
|
||||
}
|
||||
|
||||
|
||||
void FileSystem::setFileReadOnlyWeak(const QString& filename, bool readonly)
|
||||
{
|
||||
QFile file(filename);
|
||||
QFile::Permissions permissions = file.permissions();
|
||||
|
||||
if (!readonly && (permissions & QFile::WriteOwner)) {
|
||||
return; // already writable enough
|
||||
}
|
||||
|
||||
setFileReadOnly(filename, readonly);
|
||||
}
|
||||
|
||||
time_t FileSystem::getModTime(const QString &filename)
|
||||
{
|
||||
csync_vio_file_stat_t* stat = csync_vio_file_stat_new();
|
||||
|
|
|
@ -55,6 +55,17 @@ void OWNCLOUDSYNC_EXPORT setFileHidden(const QString& filename, bool hidden);
|
|||
*/
|
||||
void OWNCLOUDSYNC_EXPORT setFileReadOnly(const QString& filename, bool readonly);
|
||||
|
||||
/**
|
||||
* @brief Marks the file as read-only.
|
||||
*
|
||||
* It's like setFileReadOnly(), but weaker: if readonly is false and the user
|
||||
* already has write permissions, no change to the permissions is made.
|
||||
*
|
||||
* 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 OWNCLOUDSYNC_EXPORT setFileReadOnlyWeak(const QString& filename, bool readonly);
|
||||
|
||||
/** convert a "normal" windows path into a path that can be 32k chars long. */
|
||||
QString OWNCLOUDSYNC_EXPORT longWinPath( const QString& inpath );
|
||||
|
||||
|
|
|
@ -671,7 +671,7 @@ void PropagateDownloadFileQNAM::downloadFinished()
|
|||
}
|
||||
|
||||
// Apply the remote permissions
|
||||
FileSystem::setFileReadOnly(_tmpFile.fileName(),
|
||||
FileSystem::setFileReadOnlyWeak(_tmpFile.fileName(),
|
||||
!_item->_remotePerm.contains('W'));
|
||||
|
||||
QString error;
|
||||
|
|
|
@ -493,7 +493,7 @@ int SyncEngine::treewalkFile( TREE_WALK_FILE *file, bool remote )
|
|||
SyncJournalFileRecord prev = _journal->getFileRecord(item->_file);
|
||||
if (prev._remotePerm.contains('W') != item->_remotePerm.contains('W')) {
|
||||
const bool isReadOnly = !item->_remotePerm.contains('W');
|
||||
FileSystem::setFileReadOnly(filePath, isReadOnly);
|
||||
FileSystem::setFileReadOnlyWeak(filePath, isReadOnly);
|
||||
}
|
||||
|
||||
_journal->setFileRecordMetadata(SyncJournalFileRecord(*item, filePath));
|
||||
|
|
Loading…
Reference in a new issue