[Pkg-owncloud-commits] [owncloud-client] 17/219: JournalDB: Do prepare the queries even if the db update failed.

Sandro Knauß hefee-guest at moszumanska.debian.org
Sat Oct 11 14:43:04 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 cc6aa66ab0f6b09f1a1ec17ab5d5b2a4bbfd0132
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Wed Aug 27 14:00:20 2014 +0200

    JournalDB: Do prepare the queries even if the db update failed.
    
    Also, add more logging in case SQL errors happen while db structure
    update.
---
 src/mirall/syncjournaldb.cpp | 83 ++++++++++++++++++++++++++------------------
 1 file changed, 49 insertions(+), 34 deletions(-)

diff --git a/src/mirall/syncjournaldb.cpp b/src/mirall/syncjournaldb.cpp
index 35a51ba..211792f 100644
--- a/src/mirall/syncjournaldb.cpp
+++ b/src/mirall/syncjournaldb.cpp
@@ -227,51 +227,51 @@ bool SyncJournalDb::checkConnect()
     commitInternal("checkConnect");
 
     bool rc = updateDatabaseStructure();
-    if( rc ) {
-        _getFileRecordQuery.reset(new QSqlQuery(_db));
-        _getFileRecordQuery->prepare("SELECT path, inode, uid, gid, mode, modtime, type, md5, fileid, remotePerm FROM "
-                                     "metadata WHERE phash=:ph" );
 
-        _setFileRecordQuery.reset(new QSqlQuery(_db) );
-        _setFileRecordQuery->prepare("INSERT OR REPLACE INTO metadata "
-                                     "(phash, pathlen, path, inode, uid, gid, mode, modtime, type, md5, fileid, remotePerm) "
-                                     "VALUES ( ? , ?, ? , ? , ? , ? , ?,  ? , ? , ?, ?, ? )" );
+    _getFileRecordQuery.reset(new QSqlQuery(_db));
+    _getFileRecordQuery->prepare("SELECT path, inode, uid, gid, mode, modtime, type, md5, fileid, remotePerm FROM "
+                                 "metadata WHERE phash=:ph" );
 
-        _getDownloadInfoQuery.reset(new QSqlQuery(_db) );
-        _getDownloadInfoQuery->prepare( "SELECT tmpfile, etag, errorcount FROM "
-                                        "downloadinfo WHERE path=:pa" );
+    _setFileRecordQuery.reset(new QSqlQuery(_db) );
+    _setFileRecordQuery->prepare("INSERT OR REPLACE INTO metadata "
+                                 "(phash, pathlen, path, inode, uid, gid, mode, modtime, type, md5, fileid, remotePerm) "
+                                 "VALUES ( ? , ?, ? , ? , ? , ? , ?,  ? , ? , ?, ?, ? )" );
 
-        _setDownloadInfoQuery.reset(new QSqlQuery(_db) );
-        _setDownloadInfoQuery->prepare( "INSERT OR REPLACE INTO downloadinfo "
-                                        "(path, tmpfile, etag, errorcount) "
-                                        "VALUES ( ? , ?, ? , ? )" );
+    _getDownloadInfoQuery.reset(new QSqlQuery(_db) );
+    _getDownloadInfoQuery->prepare( "SELECT tmpfile, etag, errorcount FROM "
+                                    "downloadinfo WHERE path=:pa" );
 
-        _deleteDownloadInfoQuery.reset(new QSqlQuery(_db) );
-        _deleteDownloadInfoQuery->prepare( "DELETE FROM downloadinfo WHERE path=?" );
+    _setDownloadInfoQuery.reset(new QSqlQuery(_db) );
+    _setDownloadInfoQuery->prepare( "INSERT OR REPLACE INTO downloadinfo "
+                                    "(path, tmpfile, etag, errorcount) "
+                                    "VALUES ( ? , ?, ? , ? )" );
 
-        _getUploadInfoQuery.reset(new QSqlQuery(_db));
-        _getUploadInfoQuery->prepare( "SELECT chunk, transferid, errorcount, size, modtime FROM "
-                                      "uploadinfo WHERE path=:pa" );
+    _deleteDownloadInfoQuery.reset(new QSqlQuery(_db) );
+    _deleteDownloadInfoQuery->prepare( "DELETE FROM downloadinfo WHERE path=?" );
 
-        _setUploadInfoQuery.reset(new QSqlQuery(_db));
-        _setUploadInfoQuery->prepare( "INSERT OR REPLACE INTO uploadinfo "
-                                      "(path, chunk, transferid, errorcount, size, modtime) "
-                                      "VALUES ( ? , ?, ? , ? ,  ? , ? )");
+    _getUploadInfoQuery.reset(new QSqlQuery(_db));
+    _getUploadInfoQuery->prepare( "SELECT chunk, transferid, errorcount, size, modtime FROM "
+                                  "uploadinfo WHERE path=:pa" );
 
-        _deleteUploadInfoQuery.reset(new QSqlQuery(_db));
-        _deleteUploadInfoQuery->prepare("DELETE FROM uploadinfo WHERE path=?" );
+    _setUploadInfoQuery.reset(new QSqlQuery(_db));
+    _setUploadInfoQuery->prepare( "INSERT OR REPLACE INTO uploadinfo "
+                                  "(path, chunk, transferid, errorcount, size, modtime) "
+                                  "VALUES ( ? , ?, ? , ? ,  ? , ? )");
 
+    _deleteUploadInfoQuery.reset(new QSqlQuery(_db));
+    _deleteUploadInfoQuery->prepare("DELETE FROM uploadinfo WHERE path=?" );
 
-        _deleteFileRecordPhash.reset(new QSqlQuery(_db));
-        _deleteFileRecordPhash->prepare("DELETE FROM metadata WHERE phash=?");
 
-        _deleteFileRecordRecursively.reset(new QSqlQuery(_db));
-        _deleteFileRecordRecursively->prepare("DELETE FROM metadata WHERE path LIKE(?||'/%')");
+    _deleteFileRecordPhash.reset(new QSqlQuery(_db));
+    _deleteFileRecordPhash->prepare("DELETE FROM metadata WHERE phash=?");
+
+    _deleteFileRecordRecursively.reset(new QSqlQuery(_db));
+    _deleteFileRecordRecursively->prepare("DELETE FROM metadata WHERE path LIKE(?||'/%')");
+
+    _blacklistQuery.reset(new QSqlQuery(_db));
+    _blacklistQuery->prepare("SELECT lastTryEtag, lastTryModtime, retrycount, errorstring "
+                             "FROM blacklist WHERE path=:path");
 
-        _blacklistQuery.reset(new QSqlQuery(_db));
-        _blacklistQuery->prepare("SELECT lastTryEtag, lastTryModtime, retrycount, errorstring "
-                                 "FROM blacklist WHERE path=:path");
-    }
     return rc;
 }
 
@@ -315,10 +315,16 @@ bool SyncJournalDb::updateDatabaseStructure()
         QSqlQuery query(_db);
         query.prepare("ALTER TABLE metadata ADD COLUMN fileid VARCHAR(128);");
         re = query.exec();
+        if(!re) {
+            qDebug() << Q_FUNC_INFO << "SQL Error " << query.lastError().text();
+        }
 
         query.prepare("CREATE INDEX metadata_file_id ON metadata(fileid);");
         re = re && query.exec();
 
+        if(!re) {
+            qDebug() << Q_FUNC_INFO << "SQL Error " << query.lastError().text();
+        }
         commitInternal("update database structure: add fileid col");
     }
     if( columns.indexOf(QLatin1String("remotePerm")) == -1 ) {
@@ -326,6 +332,9 @@ bool SyncJournalDb::updateDatabaseStructure()
         QSqlQuery query(_db);
         query.prepare("ALTER TABLE metadata ADD COLUMN remotePerm VARCHAR(128);");
         re = re && query.exec();
+        if(!re) {
+            qDebug() << Q_FUNC_INFO << "SQL Error " << query.lastError().text();
+        }
         commitInternal("update database structure (remotePerm");
     }
 
@@ -334,6 +343,9 @@ bool SyncJournalDb::updateDatabaseStructure()
         query.prepare("CREATE INDEX IF NOT EXISTS metadata_inode ON metadata(inode);");
         re = re && query.exec();
 
+        if(!re) {
+            qDebug() << Q_FUNC_INFO << "SQL Error " << query.lastError().text();
+        }
         commitInternal("update database structure: add inode index");
 
     }
@@ -343,6 +355,9 @@ bool SyncJournalDb::updateDatabaseStructure()
         query.prepare("CREATE INDEX IF NOT EXISTS metadata_pathlen ON metadata(pathlen);");
         re = re && query.exec();
 
+        if(!re) {
+            qDebug() << Q_FUNC_INFO << "SQL Error " << query.lastError().text();
+        }
         commitInternal("update database structure: add pathlen index");
 
     }

-- 
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