[gnome-games] application: Create .version file on new installs
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] application: Create .version file on new installs
- Date: Fri, 20 Mar 2020 16:46:54 +0000 (UTC)
commit 6b651ef57a656ddd518b338d75cce04bb88b9a7c
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Fri Mar 20 21:42:24 2020 +0500
application: Create .version file on new installs
Avoid triggering the migration next time the app is launched. Can't
believe I never noticed this.
src/ui/application.vala | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/src/ui/application.vala b/src/ui/application.vala
index 5bf626d5..9e5da94f 100644
--- a/src/ui/application.vala
+++ b/src/ui/application.vala
@@ -51,7 +51,7 @@ public class Games.Application : Gtk.Application {
add_actions ();
add_signal_handlers ();
- try_make_dir (get_data_dir ());
+ make_data_dir ();
var database_path = get_database_path ();
try {
@@ -125,6 +125,22 @@ public class Games.Application : Gtk.Application {
return @"$cache_dir/$dir_name/$size";
}
+ private void make_data_dir () {
+ var data_dir = File.new_for_path (get_data_dir ());
+ try {
+ if (data_dir.query_exists ())
+ return;
+
+ data_dir.make_directory_with_parents ();
+
+ var version_file = data_dir.get_child (".version");
+ version_file.create (FileCreateFlags.NONE);
+ }
+ catch (Error e) {
+ critical ("Couldn't create data dir: %s", e.message);
+ }
+ }
+
public static void try_make_dir (string path) {
var file = File.new_for_path (path);
try {
@@ -132,7 +148,7 @@ public class Games.Application : Gtk.Application {
file.make_directory_with_parents ();
}
catch (Error e) {
- warning (@"$(e.message)\n");
+ critical ("Couldn't create dir '%s': %s", path, e.message);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]