From 45b938dbd8380db96355721f20d08dbcc6c96fd3 Mon Sep 17 00:00:00 2001 From: alex-z Date: Fri, 15 Mar 2024 17:04:16 +0100 Subject: [PATCH] Bugfix. Files-lock. Inorrect readonly state for TokenLock. Signed-off-by: alex-z --- src/libsync/propagatedownload.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libsync/propagatedownload.cpp b/src/libsync/propagatedownload.cpp index 11b9935a4e6ca..f3058d8d12b12 100644 --- a/src/libsync/propagatedownload.cpp +++ b/src/libsync/propagatedownload.cpp @@ -1350,7 +1350,12 @@ 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())) { + const auto isLockOwnedByCurrentUser = _item->_lockOwnerId == propagator()->account()->davUser(); + + const auto isUserLockOwnedByCurrentUser = (_item->_lockOwnerType == SyncFileItem::LockOwnerType::UserLock && isLockOwnedByCurrentUser); + const auto isTokenLockOwnedByCurrentUser = (_item->_lockOwnerType == SyncFileItem::LockOwnerType::TokenLock && isLockOwnedByCurrentUser); + + if (_item->_locked == SyncFileItem::LockStatus::LockedItem && !isUserLockOwnedByCurrentUser && !isTokenLockOwnedByCurrentUser) { qCDebug(lcPropagateDownload()) << fn << "file is locked: making it read only"; FileSystem::setFileReadOnly(fn, true); } else {