Skip to content

Commit

Permalink
Make sure notes folder always exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip-Scott committed Dec 21, 2018
1 parent aa25453 commit fa0cf30
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,15 @@ public class ENotes.Application : Granite.Application {
ENotes.app = this;
settings = ENotes.Services.Settings.get_instance ();

var notes_path = Path.build_filename (GLib.Environment.get_home_dir (), "/.local/share/notes-up/");
var notes_dir = File.new_for_path (notes_path);

if (!notes_dir.query_exists ()) {
DirUtils.create_with_parents (notes_path, 0766);
}

if (settings.notes_database == "") { // Init databases
var notes_dir = GLib.Environment.get_home_dir () + "/.local/share/notes-up/";
DirUtils.create_with_parents (notes_dir, 0766);
settings.notes_database = notes_dir + "NotesUp.db";
settings.notes_database = Path.build_filename (notes_path, "NotesUp.db");
}

ENotes.NOTES_DIR = settings.notes_location;
Expand Down
2 changes: 0 additions & 2 deletions src/Services/DatabaseTable.vala
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public abstract class DatabaseTable {
// Open DB.
int res = Sqlite.Database.open_v2 (filename, out db, Sqlite.OPEN_READWRITE | Sqlite.OPEN_CREATE,
null);
assert (res == Sqlite.OK);

// Check if we have write access to database.
if (filename != Db.IN_MEMORY_NAME) {
Expand Down Expand Up @@ -448,4 +447,3 @@ public abstract class DatabaseTable {
throw_error ("commit_transaction", res);
}
}

0 comments on commit fa0cf30

Please sign in to comment.