New discovery algo: Handle Database error
authorOlivier Goffart <ogoffart@woboq.com>
Mon, 6 Aug 2018 08:31:37 +0000 (10:31 +0200)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:58:01 +0000 (10:58 +0100)
src/libsync/discovery.cpp
src/libsync/discovery.h

index 8e2d183bb92b6d1606ef787968580668aec45f44..7498c77b3dbbe5735380cbec5691bccbb2f4d7c3 100644 (file)
@@ -205,7 +205,8 @@ void ProcessDirectoryJob::process()
                 entriesNames.insert(name);
                 dbEntriesHash[name] = rec;
             })) {
-            qFatal("TODO: DB ERROR HANDLING");
+            dbError();
+            return;
         }
     }
 
@@ -237,7 +238,8 @@ void ProcessDirectoryJob::process()
             continue;
 
         if (_queryServer != ParentNotChanged && _queryLocal != ParentNotChanged && !_discoveryData->_statedb->getFileRecord(path._original, &record)) {
-            qFatal("TODO: DB ERROR HANDLING");
+            dbError();
+            return;
         }
         if (_queryServer == InBlackList || _discoveryData->isInSelectiveSyncBlackList(path._original)) {
             processBlacklisted(path, localEntry, record);
@@ -580,7 +582,8 @@ void ProcessDirectoryJob::processFile(PathTuple path,
                     }
                 };
                 if (!_discoveryData->_statedb->getFileRecordsByFileId(serverEntry.fileId, renameCandidateProcessing)) {
-                    qFatal("TODO: Handle DB ERROR");
+                    dbError();
+                    return;
                 }
                 if (!item) {
                     return; // We went async
@@ -749,7 +752,8 @@ void ProcessDirectoryJob::processFile(PathTuple path,
             // Check if it is a move
             OCC::SyncJournalFileRecord base;
             if (!_discoveryData->_statedb->getFileRecordByInode(localEntry.inode, &base)) {
-                qFatal("TODO: handle DB Errors");
+                dbError();
+                return;
             }
             bool isMove = base.isValid() && base._type == item->_type
                 && ((base._modtime == localEntry.modtime && base._fileSize == localEntry.size) || item->_type == ItemTypeDirectory);
@@ -1141,4 +1145,10 @@ void ProcessDirectoryJob::abort()
     // This should delete all the sub jobs, and so abort everything
     deleteLater();
 }
+
+void ProcessDirectoryJob::dbError()
+{
+    _discoveryData->fatalError(tr("Error while reading the database"));
+    emit finished();
+}
 }
index c7f62e9c58e91b14d2735889629e937eb8b51761..2218becaf493b7a576fd209c5cf80811bb21bb85 100644 (file)
@@ -81,6 +81,9 @@ private:
     void subJobFinished();
     void progress();
 
+    /** An DB operation failed */
+    void dbError();
+
     QVector<RemoteInfo> _serverEntries;
     QVector<LocalInfo> _localEntries;
     RemotePermissions _rootPermissions;