diff options
author | Diego Escalante Urrelo <diegoe@igalia.com> | 2012-04-07 04:06:08 +0800 |
---|---|---|
committer | Diego Escalante Urrelo <diegoe@igalia.com> | 2012-04-11 23:27:21 +0800 |
commit | 9757561f0f99d7d39fd0d49549fad5bd181afbe5 (patch) | |
tree | b1e44c97eeac6f854ade4b7600357fb4c2274bd7 /lib | |
parent | 8cad79a78ae4995e8a3677ff510b1c3fe955bfa2 (diff) | |
download | gsoc2013-epiphany-9757561f0f99d7d39fd0d49549fad5bd181afbe5.tar gsoc2013-epiphany-9757561f0f99d7d39fd0d49549fad5bd181afbe5.tar.gz gsoc2013-epiphany-9757561f0f99d7d39fd0d49549fad5bd181afbe5.tar.bz2 gsoc2013-epiphany-9757561f0f99d7d39fd0d49549fad5bd181afbe5.tar.lz gsoc2013-epiphany-9757561f0f99d7d39fd0d49549fad5bd181afbe5.tar.xz gsoc2013-epiphany-9757561f0f99d7d39fd0d49549fad5bd181afbe5.tar.zst gsoc2013-epiphany-9757561f0f99d7d39fd0d49549fad5bd181afbe5.zip |
e-file-helpers: catch GErrors in switch_temp_file
The GFile API provides useful error messages, print them when any
operation fails to aid debugging.
https://bugzilla.gnome.org/show_bug.cgi?id=673666
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ephy-file-helpers.c | 53 |
1 files changed, 41 insertions, 12 deletions
diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c index bdb820773..d34545a18 100644 --- a/lib/ephy-file-helpers.c +++ b/lib/ephy-file-helpers.c @@ -504,6 +504,7 @@ ephy_file_switch_temp_file (GFile *file_dest, gboolean dest_exists; gboolean retval = TRUE; GFile *backup_file; + GError *error = NULL; file_dest_path = g_file_get_path (file_dest); file_temp_path = g_file_get_path (file_temp); @@ -517,10 +518,17 @@ ephy_file_switch_temp_file (GFile *file_dest, { if (g_file_move (file_dest, backup_file, G_FILE_COPY_OVERWRITE, - NULL, NULL, NULL, NULL) == FALSE) + NULL, NULL, NULL, &error) == FALSE) { - g_warning ("Failed to backup %s to %s", - file_dest_path, backup_path); + g_warning ("Failed to backup %s to %s: %s", + file_dest_path, backup_path, + error ? error->message : "No error set"); + + if (error) + { + g_error_free (error); + error = NULL; + } retval = FALSE; goto failed; @@ -529,17 +537,31 @@ ephy_file_switch_temp_file (GFile *file_dest, if (g_file_move (file_temp, file_dest, G_FILE_COPY_OVERWRITE, - NULL, NULL, NULL, NULL) == FALSE) + NULL, NULL, NULL, &error) == FALSE) { - g_warning ("Failed to replace %s with %s", - file_temp_path, file_dest_path); + g_warning ("Failed to replace %s with %s: %s", + file_temp_path, file_dest_path, + error ? error->message : "No error set"); + + if (error) + { + g_error_free (error); + error = NULL; + } if (g_file_move (backup_file, file_dest, G_FILE_COPY_OVERWRITE, - NULL, NULL, NULL, NULL) == FALSE) + NULL, NULL, NULL, &error) == FALSE) { - g_warning ("Failed to restore %s from %s", - file_dest_path, file_temp_path); + g_warning ("Failed to restore %s from %s: %s", + file_dest_path, file_temp_path, + error ? error->message : "No error set"); + + if (error) + { + g_error_free (error); + error = NULL; + } } retval = FALSE; @@ -548,10 +570,17 @@ ephy_file_switch_temp_file (GFile *file_dest, if (dest_exists) { - if (g_file_delete (backup_file, - NULL, NULL) == FALSE) + if (g_file_delete (backup_file, NULL, &error) == FALSE) { - g_warning ("Failed to delete old file %s", backup_path); + g_warning ("Failed to delete old file %s: %s", + backup_path, + error ? error->message : "No error set"); + + if (error) + { + g_error_free (error); + error = NULL; + } } } |