summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2017-10-23 17:11:43 +0200
committerOndrej Holy <oholy@redhat.com>2017-12-13 08:28:59 +0100
commitb77ad0a77df1acec5e5113338de7f48a49c8cd6d (patch)
treeb9d753373876cb039621370d0c44d8923039dee8
parenta647919841e16ea52bdc12387bcbfd5c0cc5435c (diff)
downloadgvfs-b77ad0a77df1acec5e5113338de7f48a49c8cd6d.tar.gz
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
-rw-r--r--daemon/trashlib/trashdir.c4
-rw-r--r--daemon/trashlib/trashitem.c20
-rw-r--r--daemon/trashlib/trashitem.h1
3 files changed, 12 insertions, 13 deletions
diff --git a/daemon/trashlib/trashdir.c b/daemon/trashlib/trashdir.c
index a11e0980..7875b007 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 dbc93079..08912856 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 ad782028..f4885db5 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,