mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-27 17:37:36 +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
|
// Sanity check
|
||||||
if (!_journal->checkConnect()) {
|
if (!_journal->isConnected()) {
|
||||||
qDebug() << "Bailing out, DB failure";
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -546,6 +549,9 @@ void SyncEngine::slotUpdateFinished(int updateResult)
|
||||||
emit aboutToRemoveAllFiles(_syncedItems.first()._direction, &cancel);
|
emit aboutToRemoveAllFiles(_syncedItems.first()._direction, &cancel);
|
||||||
if (cancel) {
|
if (cancel) {
|
||||||
qDebug() << Q_FUNC_INFO << "Abort sync";
|
qDebug() << Q_FUNC_INFO << "Abort sync";
|
||||||
|
emit finished();
|
||||||
|
_syncMutex.unlock();
|
||||||
|
_thread.quit();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -819,5 +819,12 @@ SyncJournalDb::~SyncJournalDb()
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SyncJournalDb::isConnected()
|
||||||
|
{
|
||||||
|
QMutexLocker lock(&_mutex);
|
||||||
|
return checkConnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace Mirall
|
} // namespace Mirall
|
||||||
|
|
|
@ -25,6 +25,11 @@ namespace Mirall {
|
||||||
class SyncJournalFileRecord;
|
class SyncJournalFileRecord;
|
||||||
class SyncJournalBlacklistRecord;
|
class SyncJournalBlacklistRecord;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class that handle the sync database
|
||||||
|
*
|
||||||
|
* This class is thread safe. All public function are locking the mutex.
|
||||||
|
*/
|
||||||
class SyncJournalDb : public QObject
|
class SyncJournalDb : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -75,7 +80,11 @@ public:
|
||||||
|
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
bool checkConnect();
|
/**
|
||||||
|
* return true if everything is correct
|
||||||
|
*/
|
||||||
|
bool isConnected();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,6 +100,7 @@ private:
|
||||||
void startTransaction();
|
void startTransaction();
|
||||||
void commitTransaction();
|
void commitTransaction();
|
||||||
QStringList tableColumns( const QString& table );
|
QStringList tableColumns( const QString& table );
|
||||||
|
bool checkConnect();
|
||||||
|
|
||||||
QSqlDatabase _db;
|
QSqlDatabase _db;
|
||||||
QString _dbFile;
|
QString _dbFile;
|
||||||
|
|
Loading…
Reference in a new issue