mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
always propagate locked status to read-only or read/write for real file
make sure that a file locked that would not be modifiable by the current client is read-only on storage also make sure we make a file read/write when modification can happen again Close #5537 Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
This commit is contained in:
parent
cb4ec73787
commit
0039ffd7da
@ -1198,6 +1198,16 @@ 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);
|
||||
} else {
|
||||
qCDebug(lcPropagateDownload()) << _tmpFile << "file is not locked: making it"
|
||||
<< ((!_item->_remotePerm.isNull() && !_item->_remotePerm.hasPermission(RemotePermissions::CanWrite)) ? "read only"
|
||||
: "read write");
|
||||
FileSystem::setFileReadOnly(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));
|
||||
|
||||
@ -1262,12 +1272,6 @@ void PropagateDownloadFile::downloadFinished()
|
||||
return;
|
||||
}
|
||||
|
||||
qCInfo(lcPropagateDownload()) << propagator()->account()->davUser() << propagator()->account()->davDisplayName() << propagator()->account()->displayName();
|
||||
if (_item->_locked == SyncFileItem::LockStatus::LockedItem && (_item->_lockOwnerType != SyncFileItem::LockOwnerType::UserLock || _item->_lockOwnerId != propagator()->account()->davUser())) {
|
||||
qCInfo(lcPropagateDownload()) << "file is locked: making it read only";
|
||||
FileSystem::setFileReadOnly(filename, true);
|
||||
}
|
||||
|
||||
FileSystem::setFileHidden(filename, false);
|
||||
|
||||
// Maybe we downloaded a newer version of the file than we thought we would...
|
||||
@ -1346,6 +1350,14 @@ void PropagateDownloadFile::updateMetadata(bool isConflict)
|
||||
handleRecallFile(fn, propagator()->localPath(), *propagator()->_journal);
|
||||
}
|
||||
|
||||
if (_item->_locked == SyncFileItem::LockStatus::LockedItem && (_item->_lockOwnerType != SyncFileItem::LockOwnerType::UserLock || _item->_lockOwnerId != propagator()->account()->davUser())) {
|
||||
qCDebug(lcPropagateDownload()) << fn << "file is locked: making it read only";
|
||||
FileSystem::setFileReadOnly(fn, true);
|
||||
} else {
|
||||
qCDebug(lcPropagateDownload()) << fn << "file is not locked: making it" << ((!_item->_remotePerm.isNull() && !_item->_remotePerm.hasPermission(RemotePermissions::CanWrite)) ? "read only" : "read write");
|
||||
FileSystem::setFileReadOnly(fn, (!_item->_remotePerm.isNull() && !_item->_remotePerm.hasPermission(RemotePermissions::CanWrite)));
|
||||
}
|
||||
|
||||
qint64 duration = _stopwatch.elapsed();
|
||||
if (isLikelyFinishedQuickly() && duration > 5 * 1000) {
|
||||
qCWarning(lcPropagateDownload) << "WARNING: Unexpectedly slow connection, took" << duration << "msec for" << _item->_size - _resumeStart << "bytes for" << _item->_file;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user