[gnome-video-arcade] Move the games database file.



commit c9d21b77ea2a7011a596259b0be373b291d011e9
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sun Mar 7 11:55:06 2010 -0500

    Move the games database file.
    
    Move the games database to a more sensible location.
    
       From: $(XDG_DATA_HOME)/applications/gnome-video-arcade/games.db
         To: $(XDG_DATA_HOME)/gnome-video-arcade/games.db
    
    During a database rebuild, check for the file in the old location and
    remove it, along with the directory.

 src/gva-db.c   |   17 +++++++++++++++++
 src/gva-util.c |    3 +--
 2 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/src/gva-db.c b/src/gva-db.c
index a4c941a..8fc8871 100644
--- a/src/gva-db.c
+++ b/src/gva-db.c
@@ -1709,6 +1709,7 @@ gva_db_build (GError **error)
 {
         GvaProcess *process;
         ParserData *data;
+        gchar *filename;
 
         g_return_val_if_fail (db != NULL, NULL);
 
@@ -1796,6 +1797,22 @@ gva_db_build (GError **error)
         if (!gva_db_reset (error))
                 return NULL;
 
+        /* LEGACY: In version 0.7.0, the database file was moved from
+         * $(XDG_DATA_HOME)/applications/gnome-video-arcade/games.db to
+         * $(XDG_DATA_HOME)/gnome-video-arcade/games.db.  Remove the old
+         * location to avoid leaving behind two databases.  This is a
+         * best-effort operation, so we can disregard errors. */
+        filename = g_build_filename (
+                g_get_user_data_dir (),
+                "applications", PACKAGE, "games.db", NULL);
+        if (g_file_test (filename, G_FILE_TEST_IS_REGULAR))
+        {
+                g_unlink (filename);
+                *strrchr (filename, G_DIR_SEPARATOR) = '\0';
+                g_rmdir (filename);
+        }
+        g_free (filename);
+
         process = gva_mame_list_xml (error);
         if (process == NULL)
                 return NULL;
diff --git a/src/gva-util.c b/src/gva-util.c
index 44bb9fc..af81df9 100644
--- a/src/gva-util.c
+++ b/src/gva-util.c
@@ -308,8 +308,7 @@ gva_get_user_data_dir (void)
         if (G_UNLIKELY (user_data_dir == NULL))
         {
                 user_data_dir = g_build_filename (
-                        g_get_user_data_dir (),
-                        "applications", PACKAGE, NULL);
+                        g_get_user_data_dir (), PACKAGE, NULL);
 
                 if (g_mkdir_with_parents (user_data_dir, 0777) < 0)
                         g_warning (



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]