diff options
author | Patrik Flykt <patrik.flykt@linux.intel.com> | 2012-05-18 11:44:08 +0300 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2012-05-24 16:33:43 +0300 |
commit | 6df0c9192a3dd6cfcc5108ec8f08f928902c8716 (patch) | |
tree | 4b6df056495a229e03957d738ce6e1a3c48a4116 /src/storage.c | |
parent | e2e36a26363c871a6617be99cb11602115189ba5 (diff) | |
download | connman-6df0c9192a3dd6cfcc5108ec8f08f928902c8716.tar.gz connman-6df0c9192a3dd6cfcc5108ec8f08f928902c8716.tar.bz2 connman-6df0c9192a3dd6cfcc5108ec8f08f928902c8716.zip |
storage: Remove default.profile when migration has been done
Unconditionally remove default.profile without any migration if
the currently used global settings save file exists. The current
settings formats for global and service settings were introduced
in version 0.78.
Diffstat (limited to 'src/storage.c')
-rw-r--r-- | src/storage.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/storage.c b/src/storage.c index 4c00ce0b..5fcec55c 100644 --- a/src/storage.c +++ b/src/storage.c @@ -387,21 +387,24 @@ void __connman_storage_migrate() GKeyFile *keyfile_def = NULL; GKeyFile *keyfile = NULL; GError *error = NULL; + connman_bool_t delete_old_config = TRUE; char **services, **keys, *value; int i, k, err; connman_bool_t val; + pathname = g_strdup_printf("%s/%s", STORAGEDIR, DEFAULT); + if (pathname == NULL) + return; + /* If setting file exists, migration has been done. */ keyfile = __connman_storage_load_global(); if (keyfile) { g_key_file_free(keyfile); + unlink(pathname); + g_free(pathname); return; } - pathname = g_strdup_printf("%s/%s", STORAGEDIR, DEFAULT); - if(pathname == NULL) - return; - /* If default.profile exists, create new settings file */ keyfile_def = storage_load(pathname); if (keyfile_def == NULL) @@ -427,6 +430,7 @@ void __connman_storage_migrate() keyfile = g_key_file_new(); if (keyfile == NULL) { connman_warn("Migrating %s failed", services[i]); + delete_old_config = FALSE; continue; } @@ -446,9 +450,11 @@ void __connman_storage_migrate() services[i]); if (err >= 0) DBG("migrated %s", services[i]); - else + else { connman_warn("Migrating %s failed %s", services[i], strerror(-err)); + delete_old_config = FALSE; + } } else DBG("no keys in %s", services[i]); @@ -520,12 +526,19 @@ void __connman_storage_migrate() g_key_file_set_boolean(keyfile, "WiMAX", "Enable", val); - __connman_storage_save_global(keyfile); + if (__connman_storage_save_global(keyfile) < 0) { + connman_warn("Migrating global config failed"); + delete_old_config = FALSE; + } g_key_file_free(keyfile); g_key_file_free(keyfile_def); + if (delete_old_config == TRUE) { + DBG("migration done for %s", pathname); + unlink(pathname); + } done: g_free(pathname); } |