diff --git a/src/mirall/syncjournaldb.cpp b/src/mirall/syncjournaldb.cpp index c929082f29..a36ee6f621 100644 --- a/src/mirall/syncjournaldb.cpp +++ b/src/mirall/syncjournaldb.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include "mirall/ownsql.h" #include @@ -51,6 +52,22 @@ QString SyncJournalDb::databaseFilePath() return _dbFile; } +// Note that this does not change the size of the -wal file, but it is supposed to make +// the normal .db faster since the changes from the wal will be incorporated into it. +// Then the next sync (and the SocketAPI) will have a faster access. +void SyncJournalDb::walCheckpoint() +{ + QElapsedTimer t; + t.start(); + SqlQuery pragma1(_db); + pragma1.prepare("PRAGMA wal_checkpoint(FULL);"); + if (!pragma1.exec()) { + qDebug() << pragma1.error(); + } else { + qDebug() << Q_FUNC_INFO << "took" << t.elapsed() << "msec"; + } +} + void SyncJournalDb::startTransaction() { if( _transaction == 0 ) { @@ -589,6 +606,10 @@ bool SyncJournalDb::postSyncCleanup(const QSet &items ) return false; } } + + // Incoroporate results back into main DB + walCheckpoint(); + return true; } diff --git a/src/mirall/syncjournaldb.h b/src/mirall/syncjournaldb.h index 74e9455611..dc89cdd410 100644 --- a/src/mirall/syncjournaldb.h +++ b/src/mirall/syncjournaldb.h @@ -42,6 +42,7 @@ public: bool deleteFileRecord( const QString& filename, bool recursively = false ); int getFileRecordCount(); bool exists(); + void walCheckpoint(); QString databaseFilePath(); static qint64 getPHash(const QString& );