]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
Provide error when erasing the blacklist error for an item fails during edit locally
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Fri, 7 Apr 2023 08:11:55 +0000 (16:11 +0800)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Sun, 23 Apr 2023 14:48:41 +0000 (22:48 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/editlocallyjob.cpp
src/gui/editlocallyjob.h

index 1f15e4dedf0a6b5fde831479f1cad169092dae08..de8f980af8822e93c45e417ccfb8e4713f78c54a 100644 (file)
@@ -252,7 +252,12 @@ bool EditLocallyJob::checkIfFileParentSyncIsNeeded()
 
 void EditLocallyJob::startSyncBeforeOpening()
 {
-    eraseBlacklistRecordForItem();
+    if (!eraseBlacklistRecordForItem()) {
+        showError(tr("Could not start editing locally."),
+                  tr("An error occurred trying to synchronise the file to edit locally."));
+        return;
+    }
+
     if (!checkIfFileParentSyncIsNeeded()) {
         processLocalItem();
         return;
@@ -264,20 +269,24 @@ void EditLocallyJob::startSyncBeforeOpening()
     FolderMan::instance()->forceSyncForFolder(_folderForFile);
 }
 
-void EditLocallyJob::eraseBlacklistRecordForItem()
+bool EditLocallyJob::eraseBlacklistRecordForItem()
 {
     if (!_folderForFile || !_fileParentItem) {
         qCWarning(lcEditLocallyJob) << "_folderForFile or _fileParentItem is invalid!";
-        return;
+        return false;
     }
+
     Q_ASSERT(!_folderForFile->isSyncRunning());
     if (_folderForFile->isSyncRunning()) {
         qCWarning(lcEditLocallyJob) << "_folderForFile is syncing";
-        return;
+        return false;
     }
+
     if (_folderForFile->journalDb()->errorBlacklistEntry(_fileParentItem->_file).isValid()) {
         _folderForFile->journalDb()->wipeErrorBlacklistEntry(_fileParentItem->_file);
     }
+
+    return true;
 }
 
 const QString EditLocallyJob::getRelativePathToRemoteRootForFile() const
index 9b06aedbc16b1fc6f4f88c56ee19effe589e2a78..3f215f90e4408c5d266e71534e50e242821cd196 100644 (file)
@@ -54,7 +54,6 @@ public slots:
 private slots:
     void fetchRemoteFileParentInfo();
     void startSyncBeforeOpening();
-    void eraseBlacklistRecordForItem();
 
     void startTokenRemoteCheck();
     void proceedWithSetup();
@@ -85,6 +84,7 @@ private slots:
 
 private:
     [[nodiscard]] bool checkIfFileParentSyncIsNeeded(); // returns true if sync will be needed, false otherwise
+    [[nodiscard]] bool eraseBlacklistRecordForItem();
     [[nodiscard]] const QString getRelativePathToRemoteRootForFile() const; // returns either '/' or a (relative path - Folder::remotePath()) for folders pointing to a non-root remote path e.g. '/subfolder' instead of '/'
     [[nodiscard]] const QString getRelativePathParent() const;