[glib: 2/3] glocalfile: Improve wording for error messages about trash directories
- From: Sebastian Dröge <sdroege src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 2/3] glocalfile: Improve wording for error messages about trash directories
- Date: Mon, 4 Jan 2021 15:07:33 +0000 (UTC)
commit 7f2af262bfce9de932013cdabc4f0e7be27657a3
Author: Philip Withnall <pwithnall endlessos org>
Date: Tue Dec 22 18:22:50 2020 +0000
glocalfile: Improve wording for error messages about trash directories
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Fixes: #1283
gio/glocalfile.c | 49 ++++++++++++++++++++++++++++++++++++-------------
1 file changed, 36 insertions(+), 13 deletions(-)
---
diff --git a/gio/glocalfile.c b/gio/glocalfile.c
index 709ea9f1c..f9603e053 100644
--- a/gio/glocalfile.c
+++ b/gio/glocalfile.c
@@ -2038,6 +2038,7 @@ g_local_file_trash (GFile *file,
{
uid_t uid;
char uid_str[32];
+ gboolean success;
uid = geteuid ();
g_snprintf (uid_str, sizeof (uid_str), "%lu", (unsigned long)uid);
@@ -2093,6 +2094,7 @@ g_local_file_trash (GFile *file,
/* No global trash dir, or it failed the tests, fall back to $topdir/.Trash-$uid */
dirname = g_strdup_printf (".Trash-%s", uid_str);
trashdir = g_build_filename (topdir, dirname, NULL);
+ success = TRUE;
g_free (dirname);
tried_create = FALSE;
@@ -2108,8 +2110,7 @@ g_local_file_trash (GFile *file,
g_remove (trashdir);
/* Not a directory or not owned by user, ignore */
- g_free (trashdir);
- trashdir = NULL;
+ success = FALSE;
}
}
else
@@ -2124,18 +2125,28 @@ g_local_file_trash (GFile *file,
}
else
{
- g_free (trashdir);
- trashdir = NULL;
+ success = FALSE;
}
}
}
- if (trashdir == NULL)
+ if (!success)
{
- g_free (topdir);
- g_set_io_error (error,
- _("Unable to find or create trash directory for %s"),
- file, G_IO_ERROR_NOT_SUPPORTED);
+ gchar *trashdir_display_name = NULL, *file_display_name = NULL;
+
+ trashdir_display_name = g_filename_display_name (trashdir);
+ file_display_name = g_filename_display_name (local->filename);
+ g_set_error (error, G_IO_ERROR,
+ G_IO_ERROR_NOT_SUPPORTED,
+ _("Unable to find or create trash directory %s to trash %s"),
+ trashdir_display_name, file_display_name);
+
+ g_free (trashdir_display_name);
+ g_free (file_display_name);
+
+ g_free (topdir);
+ g_free (trashdir);
+
return FALSE;
}
}
@@ -2144,21 +2155,33 @@ g_local_file_trash (GFile *file,
infodir = g_build_filename (trashdir, "info", NULL);
filesdir = g_build_filename (trashdir, "files", NULL);
- g_free (trashdir);
/* Make sure we have the subdirectories */
if ((g_mkdir (infodir, 0700) == -1 && errno != EEXIST) ||
(g_mkdir (filesdir, 0700) == -1 && errno != EEXIST))
{
+ gchar *trashdir_display_name = NULL, *file_display_name = NULL;
+
+ trashdir_display_name = g_filename_display_name (trashdir);
+ file_display_name = g_filename_display_name (local->filename);
+ g_set_error (error, G_IO_ERROR,
+ G_IO_ERROR_NOT_SUPPORTED,
+ _("Unable to find or create trash directory %s to trash %s"),
+ trashdir_display_name, file_display_name);
+
+ g_free (trashdir_display_name);
+ g_free (file_display_name);
+
g_free (topdir);
+ g_free (trashdir);
g_free (infodir);
g_free (filesdir);
- g_set_io_error (error,
- _("Unable to find or create trash directory for %s"),
- file, G_IO_ERROR_NOT_SUPPORTED);
+
return FALSE;
}
+ g_free (trashdir);
+
basename = g_path_get_basename (local->filename);
i = 1;
trashname = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]