lock token should be sent via webdav only for token lock type
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Wed, 25 Sep 2024 15:20:59 +0000 (17:20 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Thu, 26 Sep 2024 08:56:47 +0000 (08:56 +0000)
to be able to modify a locked file using token lock, we must sent it
with webdav requests

this must not be sent if the file is locked but the lock type is not a
token lock

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

index a67225d2a2337008c3a39b6d3c66155a02dec1aa..32e1192f3fa2f0845ff6648ddd080970afa02734 100644 (file)
@@ -328,7 +328,8 @@ void PropagateUploadFileNG::finishUpload()
 
     const auto fileSize = _fileToUpload._size;
     headers[QByteArrayLiteral("OC-Total-Length")] = QByteArray::number(fileSize);
-    if (_item->_locked == SyncFileItem::LockStatus::LockedItem) {
+    if (_item->_lockOwnerType == SyncFileItem::LockOwnerType::TokenLock &&
+        _item->_locked == SyncFileItem::LockStatus::LockedItem) {
         headers[QByteArrayLiteral("If")] = (QLatin1String("<") + propagator()->account()->davUrl().toString() + _fileToUpload._file + "> (<opaquelocktoken:" + _item->_lockToken.toUtf8() + ">)").toUtf8();
     }
 
index 7467b2ce315606d914743b6258b29de56917e5c7..6bab06305b756cc9ac64da8f63e2cdc5d6236b81 100644 (file)
@@ -102,7 +102,8 @@ void PropagateUploadFileV1::startNextChunk()
 
     QString path = _fileToUpload._file;
 
-    if (_item->_locked == SyncFileItem::LockStatus::LockedItem) {
+    if (_item->_lockOwnerType == SyncFileItem::LockOwnerType::TokenLock &&
+        _item->_locked == SyncFileItem::LockStatus::LockedItem) {
         headers[QByteArrayLiteral("If")] = (QLatin1String("<") + propagator()->account()->davUrl().toString() + _fileToUpload._file + "> (<opaquelocktoken:" + _item->_lockToken.toUtf8() + ">)").toUtf8();
     }