Merge lp:~midori/midori/memoryFolder into lp:midori

Proposed by Cris Dywan
Status: Merged
Approved by: Paweł Forysiuk
Approved revision: 6550
Merged at revision: 6550
Proposed branch: lp:~midori/midori/memoryFolder
Merge into: lp:midori
Diff against target: 49 lines (+10/-9)
2 files modified
extensions/notes.vala (+2/-2)
midori/midori-database.vala (+8/-7)
To merge this branch: bzr merge lp:~midori/midori/memoryFolder
Reviewer Review Type Date Requested Status
Paweł Forysiuk Approve
Review via email: mp+203429@code.launchpad.net

Commit message

Allow :memory: as folder to make schema detection work

To post a comment you must log in.
Revision history for this message
Paweł Forysiuk (tuxator) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'extensions/notes.vala'
--- extensions/notes.vala 2014-01-26 22:02:52 +0000
+++ extensions/notes.vala 2014-01-27 23:23:21 +0000
@@ -427,8 +427,8 @@
427 }427 }
428428
429 void activated (Midori.App app) {429 void activated (Midori.App app) {
430 string? config_path = this.get_config_dir ();430 string config_path = this.get_config_dir () ?? ":memory:";
431 string? db_path = config_path != null ? GLib.Path.build_path (Path.DIR_SEPARATOR_S, config_path, "notes.db") : null;431 string db_path = GLib.Path.build_path (Path.DIR_SEPARATOR_S, config_path, "notes.db");
432 try {432 try {
433 database = new Midori.Database (db_path);433 database = new Midori.Database (db_path);
434 } catch (Midori.DatabaseError schema_error) {434 } catch (Midori.DatabaseError schema_error) {
435435
=== modified file 'midori/midori-database.vala'
--- midori/midori-database.vala 2014-01-26 11:33:02 +0000
+++ midori/midori-database.vala 2014-01-27 23:23:21 +0000
@@ -130,7 +130,7 @@
130 public class Database : GLib.Object, GLib.Initable {130 public class Database : GLib.Object, GLib.Initable {
131 public Sqlite.Database? db { get { return _db; } }131 public Sqlite.Database? db { get { return _db; } }
132 protected Sqlite.Database? _db = null;132 protected Sqlite.Database? _db = null;
133 public string? path { get; protected set; default = ":memory:"; }133 public string? path { get; protected set; default = null; }
134134
135 /*135 /*
136 * A new database successfully opened for the first time.136 * A new database successfully opened for the first time.
@@ -148,14 +148,15 @@
148 }148 }
149149
150 public virtual bool init (GLib.Cancellable? cancellable = null) throws DatabaseError {150 public virtual bool init (GLib.Cancellable? cancellable = null) throws DatabaseError {
151 if (path == null)151 string real_path = path;
152 path = ":memory:";152 if (path == null || path.has_prefix (":memory:"))
153 real_path = ":memory:";
153 else if (!Path.is_absolute (path))154 else if (!Path.is_absolute (path))
154 path = Midori.Paths.get_config_filename_for_writing (path);155 real_path = Midori.Paths.get_config_filename_for_writing (path);
155 bool exists = Posix.access (path, Posix.F_OK) == 0;156 bool exists = Posix.access (real_path, Posix.F_OK) == 0;
156157
157 if (Sqlite.Database.open_v2 (path, out _db) != Sqlite.OK)158 if (Sqlite.Database.open_v2 (real_path, out _db) != Sqlite.OK)
158 throw new DatabaseError.OPEN ("Failed to open database %s".printf (path));159 throw new DatabaseError.OPEN ("Failed to open database %s".printf (real_path));
159160
160 if (db.exec ("PRAGMA journal_mode = WAL; PRAGMA cache_size = 32100;") != Sqlite.OK)161 if (db.exec ("PRAGMA journal_mode = WAL; PRAGMA cache_size = 32100;") != Sqlite.OK)
161 db.exec ("PRAGMA synchronous = NORMAL; PRAGMA temp_store = MEMORY;");162 db.exec ("PRAGMA synchronous = NORMAL; PRAGMA temp_store = MEMORY;");

Subscribers

People subscribed via source and target branches

to all changes: