[Pkg-owncloud-commits] [owncloud-client] 150/211: SyncJournalDB: WAL checkpoint at end of sync

Sandro Knauß hefee-guest at moszumanska.debian.org
Sat Oct 25 09:10:39 UTC 2014


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit fa70798fb5a9eb2eb3cc5ffd766bda15c0480489
Author: Markus Goetz <markus at woboq.com>
Date:   Tue Oct 21 15:41:11 2014 +0200

    SyncJournalDB: WAL checkpoint at end of sync
---
 src/mirall/syncjournaldb.cpp | 21 +++++++++++++++++++++
 src/mirall/syncjournaldb.h   |  1 +
 2 files changed, 22 insertions(+)

diff --git a/src/mirall/syncjournaldb.cpp b/src/mirall/syncjournaldb.cpp
index c929082..a36ee6f 100644
--- a/src/mirall/syncjournaldb.cpp
+++ b/src/mirall/syncjournaldb.cpp
@@ -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;
 }
 
diff --git a/src/mirall/syncjournaldb.h b/src/mirall/syncjournaldb.h
index 74e9455..dc89cdd 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& );

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list