aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/application.vala
diff options
context:
space:
mode:
authorMarvin W <git@larma.de>2017-03-12 13:19:04 +0100
committerMarvin W <git@larma.de>2017-03-12 14:09:32 +0100
commite8f11178ecc1a333976ba713f532fcae11931b16 (patch)
tree71ef4de63e27203780f3d5bfaa1662d97faaca16 /libdino/src/application.vala
parenta9ea0e9f87e71c60bc570066525d3e3634fbdcc0 (diff)
downloaddino-e8f11178ecc1a333976ba713f532fcae11931b16.tar.gz
dino-e8f11178ecc1a333976ba713f532fcae11931b16.zip
Move storage into user directory and fix plugin search path
Diffstat (limited to 'libdino/src/application.vala')
-rw-r--r--libdino/src/application.vala17
1 files changed, 15 insertions, 2 deletions
diff --git a/libdino/src/application.vala b/libdino/src/application.vala
index ad19a976..4b5fd274 100644
--- a/libdino/src/application.vala
+++ b/libdino/src/application.vala
@@ -8,8 +8,17 @@ public class Dino.Application : Gtk.Application {
public StreamInteractor stream_interaction;
public Plugins.Registry plugin_registry = new Plugins.Registry();
- public Application() {
- this.db = new Database("store.sqlite3");
+ public Application() throws Error {
+ if (DirUtils.create_with_parents(get_storage_dir(), 0700) == -1) {
+ throw new Error(-1, 0, @"Could not create storage dir \"$(get_storage_dir())\": $(FileUtils.error_from_errno(errno))");
+ }
+
+ // FIXME: Legacy import
+ if (FileUtils.test("store.sqlite3", FileTest.IS_REGULAR)) {
+ FileUtils.rename("store.sqlite3", Path.build_filename(get_storage_dir(), "dino.db"));
+ }
+
+ this.db = new Database(Path.build_filename(get_storage_dir(), "dino.db"));
this.stream_interaction = new StreamInteractor(db);
AvatarManager.start(stream_interaction, db);
@@ -21,5 +30,9 @@ public class Dino.Application : Gtk.Application {
ConversationManager.start(stream_interaction, db);
ChatInteraction.start(stream_interaction);
}
+
+ public static string get_storage_dir() {
+ return Path.build_filename(Environment.get_user_data_dir(), "dino");
+ }
}