From a9ec521bf133ab3ddf300c2a4752db8df6d45a46 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 6 Aug 2018 10:31:37 +0200 Subject: [PATCH] New discovery algo: Handle Database error --- src/libsync/discovery.cpp | 18 ++++++++++++++---- src/libsync/discovery.h | 3 +++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index 8e2d183bb..7498c77b3 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -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(); +} } diff --git a/src/libsync/discovery.h b/src/libsync/discovery.h index c7f62e9c5..2218becaf 100644 --- a/src/libsync/discovery.h +++ b/src/libsync/discovery.h @@ -81,6 +81,9 @@ private: void subJobFinished(); void progress(); + /** An DB operation failed */ + void dbError(); + QVector _serverEntries; QVector _localEntries; RemotePermissions _rootPermissions; -- 2.30.2