mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-24 22:15:57 +03:00
clarify when desktop client should offer to unlock a file
a file can be unlocked when: * the lock is an user lock from the current user * the lock is a token lock from the current desktop files client Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
This commit is contained in:
parent
1defd32790
commit
202be8a081
2 changed files with 15 additions and 5 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue