From 0ab2bd849bd86df4bcecedf02b1d3ff33d671aec Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 9 Jan 2023 17:11:33 +0100 Subject: [PATCH] Don't try to lock folders when editing locally Signed-off-by: Claudio Cambra --- src/gui/editlocallyjob.cpp | 19 +++++++++++++++++-- src/gui/editlocallyjob.h | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/gui/editlocallyjob.cpp b/src/gui/editlocallyjob.cpp index fc18fddd4..7764e0b05 100644 --- a/src/gui/editlocallyjob.cpp +++ b/src/gui/editlocallyjob.cpp @@ -253,7 +253,7 @@ void EditLocallyJob::startSyncBeforeOpening() { eraseBlacklistRecordForItem(); if (!checkIfFileParentSyncIsNeeded()) { - lockFile(); + processLocalItem(); return; } @@ -467,7 +467,7 @@ void EditLocallyJob::slotItemCompleted(const OCC::SyncFileItemPtr &item) if (item->_file == _relativePathToRemoteRoot) { disconnect(&_folderForFile->syncEngine(), &SyncEngine::itemCompleted, this, &EditLocallyJob::slotItemCompleted); disconnect(&_folderForFile->syncEngine(), &SyncEngine::itemDiscovered, this, &EditLocallyJob::slotItemDiscovered); - lockFile(); + processLocalItem(); } } @@ -557,6 +557,21 @@ void EditLocallyJob::openFile() }); } +void EditLocallyJob::processLocalItem() +{ + Q_ASSERT(_folderForFile); + + SyncJournalFileRecord rec; + const auto ok = _folderForFile->journalDb()->getFileRecord(_relativePathToRemoteRoot, &rec); + Q_ASSERT(ok); + + if (rec.isDirectory()) { // Directories not lock-able + openFile(); + } else { + lockFile(); + } +} + void EditLocallyJob::lockFile() { Q_ASSERT(_accountState); diff --git a/src/gui/editlocallyjob.h b/src/gui/editlocallyjob.h index 645649246..582d5049f 100644 --- a/src/gui/editlocallyjob.h +++ b/src/gui/editlocallyjob.h @@ -71,6 +71,7 @@ private slots: void slotLsColJobFinishedWithError(QNetworkReply *reply); void slotDirectoryListingIterated(const QString &name, const QMap &properties); + void processLocalItem(); void openFile(); void lockFile();