Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable-3.12] Bugfix/missing unlock command #7211

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/gui/socketapi/socketapi.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/gui/socketapi/socketapi.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/socketapi/socketapi.cpp

File src/gui/socketapi/socketapi.cpp does not conform to Custom style guidelines. (lines 1098, 1108)
* Copyright (C) by Dominik Schmidt <dev@dominik-schmidt.de>
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
* Copyright (C) by Roeland Jago Douma <roeland@famdouma.nl>
Expand Down Expand Up @@ -1094,8 +1094,9 @@
}

const auto record = fileData.journalRecord();
if (static_cast<SyncFileItem::LockOwnerType>(record._lockstate._lockOwnerType) != SyncFileItem::LockOwnerType::UserLock) {
qCDebug(lcSocketApi) << "Only user lock state or non-locked files can be affected manually!";

if (lockState == SyncFileItem::LockStatus::UnlockedItem &&
!shareFolder->accountState()->account()->fileCanBeUnlocked(shareFolder->journalDb(), fileData.folderRelativePath)) {
return;
}

Expand All @@ -1104,7 +1105,7 @@
shareFolder->path(),
shareFolder->journalDb(),
lockState,
SyncFileItem::LockOwnerType::UserLock);
(lockState == SyncFileItem::LockStatus::UnlockedItem) ? static_cast<SyncFileItem::LockOwnerType>(record._lockstate._lockOwnerType) : SyncFileItem::LockOwnerType::UserLock);

shareFolder->journalDb()->schedulePathForRemoteDiscovery(fileData.serverRelativePath);
shareFolder->scheduleThisFolderSoon();
Expand Down
13 changes: 11 additions & 2 deletions src/libsync/account.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/libsync/account.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/libsync/account.cpp

File src/libsync/account.cpp does not conform to Custom style guidelines. (lines 1026, 1032)
* Copyright (C) by Daniel Molkentin <danimo@owncloud.com>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -1018,11 +1018,20 @@
{
SyncJournalFileRecord record;
if (journal->getFileRecord(folderRelativePath, &record)) {
if (record._lockstate._lockOwnerType != static_cast<int>(SyncFileItem::LockOwnerType::UserLock)) {
if (record._lockstate._lockOwnerType == static_cast<int>(SyncFileItem::LockOwnerType::AppLock)) {
qCDebug(lcAccount()) << folderRelativePath << "cannot be unlocked: app lock";
return false;
}

if (record._lockstate._lockOwnerId != sharedFromThis()->davUser()) {
if (record._lockstate._lockOwnerType == static_cast<int>(SyncFileItem::LockOwnerType::UserLock) &&
record._lockstate._lockOwnerId != sharedFromThis()->davUser()) {
qCDebug(lcAccount()) << folderRelativePath << "cannot be unlocked: user lock from" << record._lockstate._lockOwnerId;
return false;
}

if (record._lockstate._lockOwnerType == static_cast<int>(SyncFileItem::LockOwnerType::TokenLock) &&
record._lockstate._lockToken.isEmpty()) {
qCDebug(lcAccount()) << folderRelativePath << "cannot be unlocked: token lock without known token";
return false;
}

Expand Down
3 changes: 2 additions & 1 deletion src/libsync/propagateuploadng.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/libsync/propagateuploadng.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/libsync/propagateuploadng.cpp

File src/libsync/propagateuploadng.cpp does not conform to Custom style guidelines. (lines 331)
* Copyright (C) by Olivier Goffart <ogoffart@owncloud.com>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -328,7 +328,8 @@

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();
}

Expand Down
3 changes: 2 additions & 1 deletion src/libsync/propagateuploadv1.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/libsync/propagateuploadv1.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/libsync/propagateuploadv1.cpp

File src/libsync/propagateuploadv1.cpp does not conform to Custom style guidelines. (lines 105)
* Copyright (C) by Olivier Goffart <ogoffart@owncloud.com>
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -102,7 +102,8 @@

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();
}

Expand Down
Loading