[gimp/soc-2009-dynamics] Make sure user-install always creates all needed directories



commit 885d4e968afb6d51bfc6de5dbadd3e09b89a8089
Author: Michael Natterer <mitch gimp org>
Date:   Thu Oct 15 21:23:01 2009 +0200

    Make sure user-install always creates all needed directories
    
    Always run user_install_create_files(), even if
    user_install_migrate_files() was run before, but make sure not to
    overwrite stuff that has been copied by user_install_mirgate_files().

 app/core/gimp-user-install.c |   40 ++++++++++++++++++++--------------------
 1 files changed, 20 insertions(+), 20 deletions(-)
---
diff --git a/app/core/gimp-user-install.c b/app/core/gimp-user-install.c
index f9f960a..17cde5a 100644
--- a/app/core/gimp-user-install.c
+++ b/app/core/gimp-user-install.c
@@ -169,9 +169,10 @@ gimp_user_install_run (GimpUserInstall *install)
     return FALSE;
 
   if (install->migrate)
-    return user_install_migrate_files (install);
-  else
-    return user_install_create_files (install);
+    if (! user_install_migrate_files (install))
+      return FALSE;
+
+  return user_install_create_files (install);
 }
 
 void
@@ -438,9 +439,9 @@ user_install_dir_copy (GimpUserInstall *install,
 static gboolean
 user_install_create_files (GimpUserInstall *install)
 {
-  gchar     dest[1024];
-  gchar     source[1024];
-  gint      i;
+  gchar dest[1024];
+  gchar source[1024];
+  gint  i;
 
   for (i = 0; i < G_N_ELEMENTS (gimp_user_install_items); i++)
     {
@@ -449,6 +450,9 @@ user_install_create_files (GimpUserInstall *install)
                   G_DIR_SEPARATOR,
                   gimp_user_install_items[i].name);
 
+      if (g_file_test (dest, G_FILE_TEST_EXISTS))
+        continue;
+
       switch (gimp_user_install_items[i].action)
         {
         case USER_INSTALL_MKDIR:
@@ -467,9 +471,17 @@ user_install_create_files (GimpUserInstall *install)
         }
     }
 
-  if (! gimp_tags_user_install ())
+  g_snprintf (dest, sizeof (dest), "%s%c%s",
+              gimp_directory (), G_DIR_SEPARATOR, "tags.xml");
+
+  if (! g_file_test (dest, G_FILE_TEST_IS_REGULAR))
     {
-      return FALSE;
+      /* if there was no tags.xml, install it with default tag set.
+       */
+      if (! gimp_tags_user_install ())
+        {
+          return FALSE;
+        }
     }
 
   return TRUE;
@@ -550,17 +562,5 @@ user_install_migrate_files (GimpUserInstall *install)
   gimp_rc_save (gimprc);
   g_object_unref (gimprc);
 
-  g_snprintf (dest, sizeof (dest), "%s%c%s",
-              gimp_directory (), G_DIR_SEPARATOR, "tags.xml");
-  if (! g_file_test (dest, G_FILE_TEST_IS_REGULAR))
-    {
-      /* if there was no tags.xml,
-       * install it with default tag set.*/
-      if (! gimp_tags_user_install ())
-        {
-          return FALSE;
-        }
-    }
-
   return TRUE;
 }



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