[gnome-games/gnome-3-36] application: Create .version file on new installs



commit 67aadbaca6f738ebb8ffeb45554365a45e26cb76
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 d2ab6ca2..1fc40824 100644
--- a/src/ui/application.vala
+++ b/src/ui/application.vala
@@ -40,7 +40,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 {
@@ -114,6 +114,22 @@ public class Games.Application : Gtk.Application {
                return @"$covers_dir/$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 {
@@ -121,7 +137,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]