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
1=== modified file 'extensions/notes.vala'
2--- extensions/notes.vala 2014-01-26 22:02:52 +0000
3+++ extensions/notes.vala 2014-01-27 23:23:21 +0000
4@@ -427,8 +427,8 @@
5 }
6
7 void activated (Midori.App app) {
8- string? config_path = this.get_config_dir ();
9- string? db_path = config_path != null ? GLib.Path.build_path (Path.DIR_SEPARATOR_S, config_path, "notes.db") : null;
10+ string config_path = this.get_config_dir () ?? ":memory:";
11+ string db_path = GLib.Path.build_path (Path.DIR_SEPARATOR_S, config_path, "notes.db");
12 try {
13 database = new Midori.Database (db_path);
14 } catch (Midori.DatabaseError schema_error) {
15
16=== modified file 'midori/midori-database.vala'
17--- midori/midori-database.vala 2014-01-26 11:33:02 +0000
18+++ midori/midori-database.vala 2014-01-27 23:23:21 +0000
19@@ -130,7 +130,7 @@
20 public class Database : GLib.Object, GLib.Initable {
21 public Sqlite.Database? db { get { return _db; } }
22 protected Sqlite.Database? _db = null;
23- public string? path { get; protected set; default = ":memory:"; }
24+ public string? path { get; protected set; default = null; }
25
26 /*
27 * A new database successfully opened for the first time.
28@@ -148,14 +148,15 @@
29 }
30
31 public virtual bool init (GLib.Cancellable? cancellable = null) throws DatabaseError {
32- if (path == null)
33- path = ":memory:";
34+ string real_path = path;
35+ if (path == null || path.has_prefix (":memory:"))
36+ real_path = ":memory:";
37 else if (!Path.is_absolute (path))
38- path = Midori.Paths.get_config_filename_for_writing (path);
39- bool exists = Posix.access (path, Posix.F_OK) == 0;
40+ real_path = Midori.Paths.get_config_filename_for_writing (path);
41+ bool exists = Posix.access (real_path, Posix.F_OK) == 0;
42
43- if (Sqlite.Database.open_v2 (path, out _db) != Sqlite.OK)
44- throw new DatabaseError.OPEN ("Failed to open database %s".printf (path));
45+ if (Sqlite.Database.open_v2 (real_path, out _db) != Sqlite.OK)
46+ throw new DatabaseError.OPEN ("Failed to open database %s".printf (real_path));
47
48 if (db.exec ("PRAGMA journal_mode = WAL; PRAGMA cache_size = 32100;") != Sqlite.OK)
49 db.exec ("PRAGMA synchronous = NORMAL; PRAGMA temp_store = MEMORY;");

Subscribers

People subscribed via source and target branches

to all changes: