[Pkg-owncloud-commits] [owncloud-client] 04/04: Fixed downgrade from 1.7.0~beta1 -> 1.6.3

Sandro Knauß hefee-guest at moszumanska.debian.org
Sat Sep 20 14:00:13 UTC 2014


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

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

commit a51c999ae6f266e67d3e753dfdd596a8a7fd7abb
Author: Sandro Knauß <bugs at sandroknauss.de>
Date:   Sat Sep 20 14:24:37 2014 +0200

    Fixed downgrade from 1.7.0~beta1 -> 1.6.3
    
    Closes: #761590
---
 debian/patches/0004-downgrade-db | 80 +++++++++++++++++++++++++++++++++++-----
 1 file changed, 71 insertions(+), 9 deletions(-)

diff --git a/debian/patches/0004-downgrade-db b/debian/patches/0004-downgrade-db
index ae4bb5d..804a33a 100644
--- a/debian/patches/0004-downgrade-db
+++ b/debian/patches/0004-downgrade-db
@@ -8,20 +8,82 @@ Last-Update: 2014-09-05
 This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
 Index: owncloud-client/src/mirall/syncjournaldb.cpp
 ===================================================================
---- owncloud-client.orig/src/mirall/syncjournaldb.cpp	2014-09-05 21:50:44.528829813 +0200
-+++ owncloud-client/src/mirall/syncjournaldb.cpp	2014-09-05 23:12:47.842135971 +0200
-@@ -319,6 +319,14 @@
-         commitInternal("update database structure");
+--- owncloud-client.orig/src/mirall/syncjournaldb.cpp	2014-09-20 13:40:02.862388145 +0200
++++ owncloud-client/src/mirall/syncjournaldb.cpp	2014-09-20 14:08:56.748462963 +0200
+@@ -203,6 +203,11 @@
+         return sqlFail("Create table blacklist", createQuery);
      }
  
++    if (!downgrade()) {
++        qDebug() << "downgrade 1.7.0~beta1->1.6.3 failed.";
++        return false;
++    }
++
+     QSqlQuery versionQuery("SELECT major, minor FROM version;", _db);
+     if (!versionQuery.next()) {
+         // If there was no entry in the table, it means we are likely upgrading from 1.5
+@@ -273,6 +278,52 @@
+     return rc;
+ }
+ 
++bool SyncJournalDb::downgrade()
++{
++    QStringList columns = tableColumns("metadata");
++    bool re = true;
++
++    // check if the file_id column is there and create it if not
++    if( !checkConnect() ) {
++        return false;
++    }
++
 +    if ( columns.indexOf(QLatin1String("remotePerm")) != -1 ) {
++        commitInternal("downgrade from 1.7.0->1.6.3");
 +        QSqlQuery query(_db);
-+        query.prepare("ALTER TABLE metadata DROP COLUMN fileid VARCHAR(128);");
++        query.prepare("CREATE TABLE new_metadata(phash INTEGER(8),pathlen INTEGER,path VARCHAR(4096),inode INTEGER,uid INTEGER,gid INTEGER,mode INTEGER,modtime INTEGER(8),type INTEGER,md5 VARCHAR(32), fileid VARCHAR(128), PRIMARY KEY(phash));");
 +        re = query.exec();
 +
-+        commitInternal("update database structure: downgrade from 1.7.0->1.6.3");
++        if ( not re ) {
++            commitInternal("downgrade: create temp database failed.");
++            return re;
++        }
++
++        query.prepare("INSERT INTO new_metadata SELECT phash, pathlen, path, inode, uid, gid, mode, modtime, type, md5, fileid FROM metadata;");
++        re = re && query.exec();
++
++        if ( not re ) {
++            commitInternal("downgrade: inserting old data to temp database failed.");
++            return re;
++        }
++        query.prepare("DROP TABLE metadata;");
++        re = re && query.exec();
++        query.prepare("ALTER TABLE new_metadata RENAME TO metadata;");
++        re = re && query.exec();
++        query.prepare("CREATE INDEX metadata_file_id ON metadata(fileid);");
++        re = re && query.exec();
++        query.prepare("CREATE INDEX metadata_inode ON metadata(inode);");
++        re = re && query.exec();
++        query.prepare("CREATE INDEX metadata_pathlen ON metadata(pathlen);");
++        re = re && query.exec();
++
++        commitInternal("downgrade: done.");
 +    }
 +
-     return re;
- }
- 
++    return re;
++
++}
++
+ void SyncJournalDb::close()
+ {
+     QMutexLocker locker(&_mutex);
+Index: owncloud-client/src/mirall/syncjournaldb.h
+===================================================================
+--- owncloud-client.orig/src/mirall/syncjournaldb.h	2014-09-05 21:50:44.528829813 +0200
++++ owncloud-client/src/mirall/syncjournaldb.h	2014-09-20 13:49:59.974089624 +0200
+@@ -109,6 +109,7 @@
+ private:
+     qint64 getPHash(const QString& ) const;
+     bool updateDatabaseStructure();
++    bool downgrade();
+     bool sqlFail(const QString& log, const QSqlQuery &query );
+     void commitInternal(const QString &context, bool startTrans = true);
+     void startTransaction();

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