[Pkg-owncloud-commits] [owncloud-client] 127/219: SyncJournal: Better error report for sql statements in updateDbStructure

Sandro Knauß hefee-guest at moszumanska.debian.org
Sat Oct 11 14:43:18 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 e9248066df97fdc90d263f0c588b6869bdaa8751
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Thu Sep 18 11:44:47 2014 +0200

    SyncJournal: Better error report for sql statements in updateDbStructure
    
    Also, even if the updateDatabaseStructure fails, precompile the sql
    statements.
    
    This will help to debug and maybe solve bug #2106
---
 src/mirall/syncjournaldb.cpp | 38 +++++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/src/mirall/syncjournaldb.cpp b/src/mirall/syncjournaldb.cpp
index 1f3be53..c77a223 100644
--- a/src/mirall/syncjournaldb.cpp
+++ b/src/mirall/syncjournaldb.cpp
@@ -228,6 +228,9 @@ bool SyncJournalDb::checkConnect()
     commitInternal("checkConnect");
 
     bool rc = updateDatabaseStructure();
+    if( !rc ) {
+        qDebug() << "WARN: Failed to update the database structure!";
+    }
 
     _getFileRecordQuery.reset(new QSqlQuery(_db));
     _getFileRecordQuery->prepare("SELECT path, inode, uid, gid, mode, modtime, type, md5, fileid, remotePerm FROM "
@@ -311,20 +314,19 @@ bool SyncJournalDb::updateDatabaseStructure()
     if( !checkConnect() ) {
         return false;
     }
-    if( columns.indexOf(QLatin1String("fileid")) == -1 ) {
 
+    if( columns.indexOf(QLatin1String("fileid")) == -1 ) {
         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();
+        if( !query.exec() ) {
+            sqlFail("updateDatabaseStructure: Add column fileid", query);
+            re = false;
         }
 
         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();
+        if( ! query.exec() ) {
+            sqlFail("updateDatabaseStructure: create index fileid", query);
+            re = false;
         }
         commitInternal("update database structure: add fileid col");
     }
@@ -332,9 +334,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();
+        if( !query.exec()) {
+            sqlFail("updateDatabaseStructure: add column remotePerm", query);
+            re = false;
         }
         commitInternal("update database structure (remotePerm");
     }
@@ -342,10 +344,9 @@ bool SyncJournalDb::updateDatabaseStructure()
     if( 1 ) {
         QSqlQuery query(_db);
         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();
+        if( !query.exec()) {
+            sqlFail("updateDatabaseStructure: create index inode", query);
+            re = false;
         }
         commitInternal("update database structure: add inode index");
 
@@ -354,10 +355,9 @@ bool SyncJournalDb::updateDatabaseStructure()
     if( 1 ) {
         QSqlQuery query(_db);
         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();
+        if( !query.exec()) {
+            sqlFail("updateDatabaseStructure: create index pathlen", query);
+            re = false;
         }
         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