[gconf/migration-changes: 2/7] GSettings migration: only write database on actual changes



commit 0a55ec748575c5c071e3b4ebff54dbc045d66124
Author: Ryan Lortie <desrt desrt ca>
Date:   Wed Aug 10 11:21:43 2011 +0200

    GSettings migration: only write database on actual changes
    
    The database was being rewritten in all cases of timestamp changes on
    the migration scripts directory -- possibly even if a script had been
    removed since last run (or other reasons).
    
    Only rewrite the file if a new migration has actually been run.

 gsettings/gsettings-data-convert.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/gsettings/gsettings-data-convert.c b/gsettings/gsettings-data-convert.c
index b0c8b9c..eac6fd4 100644
--- a/gsettings/gsettings-data-convert.c
+++ b/gsettings/gsettings-data-convert.c
@@ -420,6 +420,7 @@ main (int argc, char *argv[])
   struct stat statbuf;
   GError *error;
   gchar **converted;
+  gboolean changed;
   GDir *dir;
   const gchar *name;
   gchar *filename;
@@ -448,6 +449,7 @@ main (int argc, char *argv[])
     }
 
   load_state (&stored_mtime, &converted);
+  changed = FALSE;
 
   /* If the directory is not newer, exit */
   if (stat (convert_dir, &statbuf) == 0)
@@ -497,6 +499,7 @@ main (int argc, char *argv[])
           converted = g_realloc (converted, (len + 2) * sizeof (gchar *));
           converted[len] = g_strdup (name);
           converted[len + 1] = NULL;
+          changed = TRUE;
         }
 
       g_free (filename);
@@ -504,7 +507,7 @@ main (int argc, char *argv[])
  next: ;
     }
 
-  if (!dry_run)
+  if (changed && !dry_run)
     {
       if (!save_state (converted))
         return 1;



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