From 3f20f192e9d7cbc202f2b35dc60cef53f3f99ce5 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 5 Dec 2022 21:22:08 +0100 Subject: [PATCH] Ensure we are checking lock state once file has been synced after setting lock Signed-off-by: Claudio Cambra --- src/gui/editlocallyjob.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/gui/editlocallyjob.cpp b/src/gui/editlocallyjob.cpp index 489b027ed..a248c6b50 100644 --- a/src/gui/editlocallyjob.cpp +++ b/src/gui/editlocallyjob.cpp @@ -566,22 +566,23 @@ void EditLocallyJob::lockFile() return; } - _folderConnections.append(connect(_accountState->account().data(), &Account::lockFileSuccess, - this, [this] { - _folderForFile->journalDb()->schedulePathForRemoteDiscovery(_relPath); - _folderForFile->scheduleThisFolderSoon(); - })); - _folderConnections.append(connect(_folderForFile, &Folder::syncFinished, - this, [this](const OCC::SyncResult &result) { - Q_UNUSED(result) - fileLockSuccess(); + _folderForFile->setSyncPaused(true); + + _folderConnections.append(connect(&_folderForFile->syncEngine(), &SyncEngine::itemCompleted, + this, [this](const SyncFileItemPtr &item) { + if (item->_file == _relPath && item->_locked == SyncFileItem::LockStatus::LockedItem) { + fileLockSuccess(); + } })); + _folderConnections.append(connect(_accountState->account().data(), &Account::lockFileError, this, &EditLocallyJob::fileLockError)); _folderForFile->accountState()->account()->setLockFileState(_relPath, _folderForFile->journalDb(), SyncFileItem::LockStatus::LockedItem); + _folderForFile->journalDb()->schedulePathForRemoteDiscovery(_relPath); + FolderMan::instance()->forceSyncForFolder(_folderForFile); } void EditLocallyJob::disconnectFolderSignals()