mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 15:36:14 +01:00
Merge branch '1283-trash-wording' into 'master'
glocalfile: Improve wording for error messages about trash directories Closes #1283 See merge request GNOME/glib!1825
This commit is contained in:
commit
87e8eb67c3
@ -2026,7 +2026,7 @@ g_local_file_trash (GFile *file,
|
|||||||
display_name = g_filename_display_name (trashdir);
|
display_name = g_filename_display_name (trashdir);
|
||||||
g_set_error (error, G_IO_ERROR,
|
g_set_error (error, G_IO_ERROR,
|
||||||
g_io_error_from_errno (errsv),
|
g_io_error_from_errno (errsv),
|
||||||
_("Unable to create trash dir %s: %s"),
|
_("Unable to create trash directory %s: %s"),
|
||||||
display_name, g_strerror (errsv));
|
display_name, g_strerror (errsv));
|
||||||
g_free (display_name);
|
g_free (display_name);
|
||||||
g_free (trashdir);
|
g_free (trashdir);
|
||||||
@ -2038,6 +2038,7 @@ g_local_file_trash (GFile *file,
|
|||||||
{
|
{
|
||||||
uid_t uid;
|
uid_t uid;
|
||||||
char uid_str[32];
|
char uid_str[32];
|
||||||
|
gboolean success;
|
||||||
|
|
||||||
uid = geteuid ();
|
uid = geteuid ();
|
||||||
g_snprintf (uid_str, sizeof (uid_str), "%lu", (unsigned long)uid);
|
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 */
|
/* No global trash dir, or it failed the tests, fall back to $topdir/.Trash-$uid */
|
||||||
dirname = g_strdup_printf (".Trash-%s", uid_str);
|
dirname = g_strdup_printf (".Trash-%s", uid_str);
|
||||||
trashdir = g_build_filename (topdir, dirname, NULL);
|
trashdir = g_build_filename (topdir, dirname, NULL);
|
||||||
|
success = TRUE;
|
||||||
g_free (dirname);
|
g_free (dirname);
|
||||||
|
|
||||||
tried_create = FALSE;
|
tried_create = FALSE;
|
||||||
@ -2108,8 +2110,7 @@ g_local_file_trash (GFile *file,
|
|||||||
g_remove (trashdir);
|
g_remove (trashdir);
|
||||||
|
|
||||||
/* Not a directory or not owned by user, ignore */
|
/* Not a directory or not owned by user, ignore */
|
||||||
g_free (trashdir);
|
success = FALSE;
|
||||||
trashdir = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2124,18 +2125,28 @@ g_local_file_trash (GFile *file,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_free (trashdir);
|
success = FALSE;
|
||||||
trashdir = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trashdir == NULL)
|
if (!success)
|
||||||
{
|
{
|
||||||
g_free (topdir);
|
gchar *trashdir_display_name = NULL, *file_display_name = NULL;
|
||||||
g_set_io_error (error,
|
|
||||||
_("Unable to find or create trash directory for %s"),
|
trashdir_display_name = g_filename_display_name (trashdir);
|
||||||
file, G_IO_ERROR_NOT_SUPPORTED);
|
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;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2144,21 +2155,33 @@ g_local_file_trash (GFile *file,
|
|||||||
|
|
||||||
infodir = g_build_filename (trashdir, "info", NULL);
|
infodir = g_build_filename (trashdir, "info", NULL);
|
||||||
filesdir = g_build_filename (trashdir, "files", NULL);
|
filesdir = g_build_filename (trashdir, "files", NULL);
|
||||||
g_free (trashdir);
|
|
||||||
|
|
||||||
/* Make sure we have the subdirectories */
|
/* Make sure we have the subdirectories */
|
||||||
if ((g_mkdir (infodir, 0700) == -1 && errno != EEXIST) ||
|
if ((g_mkdir (infodir, 0700) == -1 && errno != EEXIST) ||
|
||||||
(g_mkdir (filesdir, 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 (topdir);
|
||||||
|
g_free (trashdir);
|
||||||
g_free (infodir);
|
g_free (infodir);
|
||||||
g_free (filesdir);
|
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;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_free (trashdir);
|
||||||
|
|
||||||
basename = g_path_get_basename (local->filename);
|
basename = g_path_get_basename (local->filename);
|
||||||
i = 1;
|
i = 1;
|
||||||
trashname = NULL;
|
trashname = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user