Merge pull request #7208 from nextcloud/bugfix/missingUnlockCommand

Bugfix/missing unlock command
This commit is contained in:
Matthieu Gallien 2024-09-26 10:56:11 +02:00 коммит произвёл GitHub
Родитель 1defd32790 c77562022d
Коммит 42c89bd9c7
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
4 изменённых файлов: 19 добавлений и 7 удалений

Просмотреть файл

@ -1110,8 +1110,9 @@ void SocketApi::setFileLock(const QString &localFile, const SyncFileItem::LockSt
}
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;
}
@ -1120,7 +1121,7 @@ void SocketApi::setFileLock(const QString &localFile, const SyncFileItem::LockSt
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();

Просмотреть файл

@ -1022,11 +1022,20 @@ bool Account::fileCanBeUnlocked(SyncJournalDb * const journal,
{
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;
}

Просмотреть файл

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

Просмотреть файл

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