]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
set read only/read file on the newly downloaded file
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Wed, 12 Jul 2023 11:38:17 +0000 (13:38 +0200)
committerMatthieu Gallien <matthieu.gallien@nextcloud.com>
Wed, 12 Jul 2023 11:42:34 +0000 (13:42 +0200)
will fix behavior on windows by properly setting the new temp file just
downloaded have the proper state (read only or read/write) and not the
already existing file that will be replaced by the newly odwnloaded one

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/libsync/propagatedownload.cpp

index 13d1ba58c6975ce93e1aea6b7089604f196be887..08ab4848915019f8ee594ed0bf3803af1080c1e9 100644 (file)
@@ -1200,17 +1200,14 @@ void PropagateDownloadFile::downloadFinished()
 
     if (_item->_locked == SyncFileItem::LockStatus::LockedItem && (_item->_lockOwnerType != SyncFileItem::LockOwnerType::UserLock || _item->_lockOwnerId != propagator()->account()->davUser())) {
         qCDebug(lcPropagateDownload()) << _tmpFile << "file is locked: making it read only";
-        FileSystem::setFileReadOnly(filename, true);
+        FileSystem::setFileReadOnly(_tmpFile.fileName(), true);
     } else {
         qCDebug(lcPropagateDownload()) << _tmpFile << "file is not locked: making it"
                                        << ((!_item->_remotePerm.isNull() && !_item->_remotePerm.hasPermission(RemotePermissions::CanWrite)) ? "read only"
                                                                                                                                             : "read write");
-        FileSystem::setFileReadOnlyWeak(filename, (!_item->_remotePerm.isNull() && !_item->_remotePerm.hasPermission(RemotePermissions::CanWrite)));
+        FileSystem::setFileReadOnlyWeak(_tmpFile.fileName(), (!_item->_remotePerm.isNull() && !_item->_remotePerm.hasPermission(RemotePermissions::CanWrite)));
     }
 
-    // Apply the remote permissions
-    FileSystem::setFileReadOnlyWeak(_tmpFile.fileName(), !_item->_remotePerm.isNull() && !_item->_remotePerm.hasPermission(RemotePermissions::CanWrite));
-
     const auto isConflict = (_item->_instruction == CSYNC_INSTRUCTION_CONFLICT
                              && (QFileInfo(filename).isDir() || !FileSystem::fileEquals(filename, _tmpFile.fileName()))) ||
         _item->_instruction == CSYNC_INSTRUCTION_CASE_CLASH_CONFLICT;