Merge lp:~ivaldi/midori/endless-user-version into lp:midori

Proposed by André Stösel
Status: Merged
Approved by: Cris Dywan
Approved revision: 6411
Merged at revision: 6410
Proposed branch: lp:~ivaldi/midori/endless-user-version
Merge into: lp:midori
Diff against target: 39 lines (+6/-7)
1 file modified
midori/midori-database.vala (+6/-7)
To merge this branch: bzr merge lp:~ivaldi/midori/endless-user-version
Reviewer Review Type Date Requested Status
Cris Dywan Approve
Review via email: mp+186934@code.launchpad.net

Commit message

fix endless loop in Midori.Database.init

To post a comment you must log in.
6411. By André Stösel

begin with Update1.sql instead of Update2.sql

Revision history for this message
Cris Dywan (kalikiana) wrote :

Nice stuff.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'midori/midori-database.vala'
--- midori/midori-database.vala 2013-09-17 23:39:10 +0000
+++ midori/midori-database.vala 2013-09-22 13:49:02 +0000
@@ -51,30 +51,29 @@
51 db.exec ("PRAGMA synchronous = NORMAL; PRAGMA temp_store = MEMORY;");51 db.exec ("PRAGMA synchronous = NORMAL; PRAGMA temp_store = MEMORY;");
52 db.exec ("PRAGMA count_changes = OFF;");52 db.exec ("PRAGMA count_changes = OFF;");
5353
54 int64 version, user_version;54 int64 user_version;
55 Sqlite.Statement stmt;55 Sqlite.Statement stmt;
56 if (db.prepare_v2 ("PRAGMA user_version;", -1, out stmt, null) != Sqlite.OK)56 if (db.prepare_v2 ("PRAGMA user_version;", -1, out stmt, null) != Sqlite.OK)
57 throw new DatabaseError.EXECUTE ("Failed to compile statement %s".printf (db.errmsg ()));57 throw new DatabaseError.EXECUTE ("Failed to compile statement %s".printf (db.errmsg ()));
58 if (stmt.step () != Sqlite.ROW)58 if (stmt.step () != Sqlite.ROW)
59 throw new DatabaseError.EXECUTE ("Failed to get row %s".printf (db.errmsg ()));59 throw new DatabaseError.EXECUTE ("Failed to get row %s".printf (db.errmsg ()));
60 version = user_version = stmt.column_int64 (0);60 user_version = stmt.column_int64 (0);
6161
62 if (version == 0) {62 if (user_version == 0) {
63 exec_script ("Create");63 exec_script ("Create");
64 user_version = version = 1;64 user_version = 1;
65 exec ("PRAGMA user_version = " + user_version.to_string ());65 exec ("PRAGMA user_version = " + user_version.to_string ());
66 }66 }
6767
68 while (true) {68 while (true) {
69 int64 new_version = version + 1;
70 try {69 try {
71 exec_script ("Update" + new_version.to_string ());70 exec_script ("Update" + user_version.to_string ());
72 } catch (DatabaseError error) {71 } catch (DatabaseError error) {
73 if (error is DatabaseError.FILENAME)72 if (error is DatabaseError.FILENAME)
74 break;73 break;
75 throw error;74 throw error;
76 }75 }
77 user_version = new_version;76 user_version = user_version + 1;
78 exec ("PRAGMA user_version = " + user_version.to_string ());77 exec ("PRAGMA user_version = " + user_version.to_string ());
79 }78 }
8079

Subscribers

People subscribed via source and target branches

to all changes: