mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-27 09:30:13 +03:00
Fix some error cases in the SyncEngine
Always cleanup properly when we bail out. Also fix thread safety of the SyncJournalDB
This commit is contained in:
parent
ded21c5826
commit
bfe6a50b19
3 changed files with 26 additions and 3 deletions
|
@ -530,9 +530,12 @@ void SyncEngine::slotUpdateFinished(int updateResult)
|
|||
}
|
||||
|
||||
// Sanity check
|
||||
if (!_journal->checkConnect()) {
|
||||
if (!_journal->isConnected()) {
|
||||
qDebug() << "Bailing out, DB failure";
|
||||
QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection); // signal
|
||||
emit csyncError(tr("Cannot open the sync journal"));
|
||||
emit finished();
|
||||
_syncMutex.unlock();
|
||||
_thread.quit();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -546,6 +549,9 @@ void SyncEngine::slotUpdateFinished(int updateResult)
|
|||
emit aboutToRemoveAllFiles(_syncedItems.first()._direction, &cancel);
|
||||
if (cancel) {
|
||||
qDebug() << Q_FUNC_INFO << "Abort sync";
|
||||
emit finished();
|
||||
_syncMutex.unlock();
|
||||
_thread.quit();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -819,5 +819,12 @@ SyncJournalDb::~SyncJournalDb()
|
|||
close();
|
||||
}
|
||||
|
||||
bool SyncJournalDb::isConnected()
|
||||
{
|
||||
QMutexLocker lock(&_mutex);
|
||||
return checkConnect();
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Mirall
|
||||
|
|
|
@ -25,6 +25,11 @@ namespace Mirall {
|
|||
class SyncJournalFileRecord;
|
||||
class SyncJournalBlacklistRecord;
|
||||
|
||||
/**
|
||||
* Class that handle the sync database
|
||||
*
|
||||
* This class is thread safe. All public function are locking the mutex.
|
||||
*/
|
||||
class SyncJournalDb : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -75,7 +80,11 @@ public:
|
|||
|
||||
void close();
|
||||
|
||||
bool checkConnect();
|
||||
/**
|
||||
* return true if everything is correct
|
||||
*/
|
||||
bool isConnected();
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -91,6 +100,7 @@ private:
|
|||
void startTransaction();
|
||||
void commitTransaction();
|
||||
QStringList tableColumns( const QString& table );
|
||||
bool checkConnect();
|
||||
|
||||
QSqlDatabase _db;
|
||||
QString _dbFile;
|
||||
|
|
Loading…
Reference in a new issue