SyncJournalDB: WAL checkpoint at end of sync

This commit is contained in:
Markus Goetz 2014-10-21 15:41:11 +02:00
parent 1af480ea3b
commit fa70798fb5
2 changed files with 22 additions and 0 deletions

View File

@ -14,6 +14,7 @@
#include <QFile>
#include <QStringList>
#include <QDebug>
#include <QElapsedTimer>
#include "mirall/ownsql.h"
#include <inttypes.h>
@ -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<QString> &items )
return false;
}
}
// Incoroporate results back into main DB
walCheckpoint();
return true;
}

View File

@ -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& );