diff options
author | Michael Catanzaro <mcatanzaro@igalia.com> | 2019-03-17 12:09:14 -0500 |
---|---|---|
committer | Michael Catanzaro <mcatanzaro@igalia.com> | 2019-03-20 09:26:40 -0500 |
commit | 9ea69e85b222a6489bceee8b76aa05449e5e2fe8 (patch) | |
tree | 32143b23c248a5918ef01a50632548e9e5335adb /src/profile-migrator | |
parent | 318e19e794b1e0b066df039116260c19e0f17dc6 (diff) | |
download | epiphany-9ea69e85b222a6489bceee8b76aa05449e5e2fe8.tar.gz |
profile-migrator: Refactor move_directory_contents() a bit
It's easier to use this function if it creates the GFiles itself,
instead of expecting every callsite to do so.
Diffstat (limited to 'src/profile-migrator')
-rw-r--r-- | src/profile-migrator/ephy-profile-migrator.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/src/profile-migrator/ephy-profile-migrator.c b/src/profile-migrator/ephy-profile-migrator.c index f599d0ef9..2c28b6763 100644 --- a/src/profile-migrator/ephy-profile-migrator.c +++ b/src/profile-migrator/ephy-profile-migrator.c @@ -1084,16 +1084,20 @@ out: } static gboolean -move_directory_contents (GFile *source, - GFile *dest) +move_directory_contents (const char *source_path, + const char *dest_path) { + g_autoptr(GFile) source = g_file_new_for_path (source_path); + g_autoptr(GFile) dest = g_file_new_for_path (dest_path); + g_autoptr(GFileEnumerator) direnum = NULL; + g_autoptr(GError) error = NULL; + /* Just a sanity check as it should already exist */ g_file_make_directory (dest, NULL, NULL); - g_autoptr(GError) error = NULL; - g_autoptr(GFileEnumerator) direnum = g_file_enumerate_children (source, G_FILE_ATTRIBUTE_STANDARD_NAME, - G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, - NULL, &error); + direnum = g_file_enumerate_children (source, G_FILE_ATTRIBUTE_STANDARD_NAME, + G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, + NULL, &error); if (error) { g_warning ("Failed to enumerate files: %s", error->message); return FALSE; @@ -1143,12 +1147,9 @@ migrate_profile_directories (void) g_autofree char *old_name = g_strconcat ("app-epiphany-", app->id, NULL); g_autofree char *old_path = g_build_filename (legacy_profile_dir (), old_name, NULL); - g_autoptr(GFile) old_directory = g_file_new_for_path (old_path); - g_autofree char *app_path = ephy_web_application_get_profile_directory (app->id); - g_autoptr(GFile) new_directory = g_file_new_for_path (app_path); - if (!move_directory_contents (old_directory, new_directory)) + if (!move_directory_contents (old_path, app_path)) continue; // Create an empty file to indicate it's an app @@ -1212,13 +1213,11 @@ migrate_profile_directories (void) if (!ephy_profile_dir_is_default ()) return; - g_autoptr(GFile) old_directory = g_file_new_for_path (legacy_default_profile_dir ()); - g_autoptr(GFile) new_directory = g_file_new_for_path (ephy_default_profile_dir ()); - - if (!move_directory_contents (old_directory, new_directory)) + if (!move_directory_contents (legacy_default_profile_dir (), ephy_default_profile_dir ())) return; /* We are also moving some cache directories so just remove the old ones */ + g_autoptr(GFile) new_directory = g_file_new_for_path (ephy_default_profile_dir ()); g_autoptr(GFile) adblock_directory = g_file_get_child (new_directory, "adblock"); g_file_delete (adblock_directory, NULL, NULL); g_autoptr(GFile) gsb_file = g_file_get_child (new_directory, "gsb-threats.db"); |