[gvfs/gnome-3-24] trash: Fix trash::orig-path for relative paths
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs/gnome-3-24] trash: Fix trash::orig-path for relative paths
- Date: Mon, 5 Mar 2018 12:13:08 +0000 (UTC)
commit b34ee1fe9fcb2d0e74e2686ca62dc2a7f4f36fec
Author: Ondrej Holy <oholy redhat com>
Date: Mon Oct 23 17:11:43 2017 +0200
trash: Fix trash::orig-path for relative paths
The trash::orig-path attribute calucaltion expects that the trash
is only one dir (i.e. .Trash, .Trash-$UID) and it fails for relative
paths in case it is not (i.e. .Trash/$UID). Let's propagate the topdir
and fix relative path handling...
https://bugzilla.gnome.org/show_bug.cgi?id=789328
daemon/trashlib/trashdir.c | 4 ++--
daemon/trashlib/trashitem.c | 20 +++++++++-----------
daemon/trashlib/trashitem.h | 1 +
3 files changed, 12 insertions(+), 13 deletions(-)
---
diff --git a/daemon/trashlib/trashdir.c b/daemon/trashlib/trashdir.c
index a11e098..7875b00 100644
--- a/daemon/trashlib/trashdir.c
+++ b/daemon/trashlib/trashdir.c
@@ -91,7 +91,7 @@ trash_dir_set_files (TrashDir *dir,
/* new entry. add it. */
*old = g_slist_prepend (*old, new->data); /* take reference */
old = &(*old)->next;
- trash_root_add_item (dir->root, new->data, dir->is_homedir);
+ trash_root_add_item (dir->root, new->data, dir->topdir, dir->is_homedir);
new = new->next;
}
else if (result > 0)
@@ -164,7 +164,7 @@ trash_dir_changed (GFileMonitor *monitor,
TrashDir *dir = user_data;
if (event_type == G_FILE_MONITOR_EVENT_CREATED)
- trash_root_add_item (dir->root, file, dir->is_homedir);
+ trash_root_add_item (dir->root, file, dir->topdir, dir->is_homedir);
else if (event_type == G_FILE_MONITOR_EVENT_DELETED)
trash_root_remove_item (dir->root, file, dir->is_homedir);
diff --git a/daemon/trashlib/trashitem.c b/daemon/trashlib/trashitem.c
index dbc9307..0891285 100644
--- a/daemon/trashlib/trashitem.c
+++ b/daemon/trashlib/trashitem.c
@@ -135,6 +135,7 @@ trash_item_escape_name (GFile *file,
static void
trash_item_get_trashinfo (GFile *path,
+ GFile *topdir,
GFile **original,
char **date)
{
@@ -178,13 +179,8 @@ trash_item_get_trashinfo (GFile *path,
if (g_path_is_absolute (decoded))
*original = g_file_new_for_path (decoded);
else
- {
- GFile *rootdir;
-
- rootdir = g_file_get_parent (trashdir);
- *original = g_file_get_child (rootdir, decoded);
- g_object_unref (rootdir);
- }
+ *original = g_file_get_child (topdir, decoded);
+
g_free (decoded);
}
@@ -202,8 +198,9 @@ trash_item_get_trashinfo (GFile *path,
static TrashItem *
trash_item_new (TrashRoot *root,
- GFile *file,
- gboolean in_homedir)
+ GFile *file,
+ GFile *topdir,
+ gboolean in_homedir)
{
TrashItem *item;
@@ -212,7 +209,7 @@ trash_item_new (TrashRoot *root,
item->ref_count = 1;
item->file = g_object_ref (file);
item->escaped_name = trash_item_escape_name (file, in_homedir);
- trash_item_get_trashinfo (item->file, &item->original, &item->delete_date);
+ trash_item_get_trashinfo (item->file, topdir, &item->original, &item->delete_date);
return item;
}
@@ -370,11 +367,12 @@ trash_root_free (TrashRoot *root)
void
trash_root_add_item (TrashRoot *list,
GFile *file,
+ GFile *topdir,
gboolean in_homedir)
{
TrashItem *item;
- item = trash_item_new (list, file, in_homedir);
+ item = trash_item_new (list, file, topdir, in_homedir);
g_rw_lock_writer_lock (&list->lock);
diff --git a/daemon/trashlib/trashitem.h b/daemon/trashlib/trashitem.h
index ad78202..f4885db 100644
--- a/daemon/trashlib/trashitem.h
+++ b/daemon/trashlib/trashitem.h
@@ -28,6 +28,7 @@ void trash_root_free (TrashRoot *root);
/* add/remove trash items (safe only from one thread) */
void trash_root_add_item (TrashRoot *root,
GFile *file,
+ GFile *topdir,
gboolean in_homedir);
void trash_root_remove_item (TrashRoot *root,
GFile *file,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]