[epiphany/gnome-3-32] profile-migrator: Refactor move_directory_contents() a bit
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/gnome-3-32] profile-migrator: Refactor move_directory_contents() a bit
- Date: Wed, 20 Mar 2019 16:14:13 +0000 (UTC)
commit 457561917d4f53d137a35de686c86df2f9e50d17
Author: Michael Catanzaro <mcatanzaro igalia com>
Date: Sun Mar 17 12:09:14 2019 -0500
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.
src/profile-migrator/ephy-profile-migrator.c | 28 +++++++++++++---------------
1 file changed, 13 insertions(+), 15 deletions(-)
---
diff --git a/src/profile-migrator/ephy-profile-migrator.c b/src/profile-migrator/ephy-profile-migrator.c
index fdc169cbf..e664214c5 100644
--- a/src/profile-migrator/ephy-profile-migrator.c
+++ b/src/profile-migrator/ephy-profile-migrator.c
@@ -1009,16 +1009,20 @@ migrate_annoyance_list (void)
}
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;
@@ -1064,14 +1068,10 @@ 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
g_autofree char *app_file = g_build_filename (app_path, ".app", NULL);
@@ -1134,13 +1134,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");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]