commit
73a8528b14
@ -0,0 +1,65 @@
|
||||
From f93bd46c36c8e42f17f0f61b79c55a3794906395 Mon Sep 17 00:00:00 2001
|
||||
From: Ondrej Holy <oholy@redhat.com>
|
||||
Date: Fri, 6 Mar 2020 10:08:09 +0100
|
||||
Subject: [PATCH] trash: Add support for x-gvfs-notrash option to ignore mounts
|
||||
|
||||
Add support for x-gvfs-notrash mount option, which allows to ignore
|
||||
trash folder on certain mounts. This might be especially useful e.g.
|
||||
to prevent wakeups of autofs mounts...
|
||||
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=1096200
|
||||
---
|
||||
daemon/trashlib/trashwatcher.c | 30 +++++++++++++++++++++++++++++-
|
||||
1 file changed, 29 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/daemon/trashlib/trashwatcher.c b/daemon/trashlib/trashwatcher.c
|
||||
index 6b455235..01c440a1 100644
|
||||
--- a/daemon/trashlib/trashwatcher.c
|
||||
+++ b/daemon/trashlib/trashwatcher.c
|
||||
@@ -211,6 +211,34 @@ trash_mount_remove (TrashMount **mount_ptr)
|
||||
g_slice_free (TrashMount, mount);
|
||||
}
|
||||
|
||||
+static gboolean
|
||||
+ignore_trash_mount (GUnixMountEntry *mount)
|
||||
+{
|
||||
+ GUnixMountPoint *mount_point = NULL;
|
||||
+ const gchar *mount_options;
|
||||
+ gboolean retval = TRUE;
|
||||
+
|
||||
+ if (g_unix_mount_is_system_internal (mount))
|
||||
+ return TRUE;
|
||||
+
|
||||
+ mount_options = g_unix_mount_get_options (mount);
|
||||
+ if (mount_options == NULL)
|
||||
+ {
|
||||
+ mount_point = g_unix_mount_point_at (g_unix_mount_get_mount_path (mount),
|
||||
+ NULL);
|
||||
+ if (mount_point != NULL)
|
||||
+ mount_options = g_unix_mount_point_get_options (mount_point);
|
||||
+ }
|
||||
+
|
||||
+ if (mount_options == NULL ||
|
||||
+ strstr (mount_options, "x-gvfs-notrash") == NULL)
|
||||
+ retval = FALSE;
|
||||
+
|
||||
+ g_clear_pointer (&mount_point, g_unix_mount_point_free);
|
||||
+
|
||||
+ return retval;
|
||||
+}
|
||||
+
|
||||
static void
|
||||
trash_watcher_remount (TrashWatcher *watcher)
|
||||
{
|
||||
@@ -229,7 +257,7 @@ trash_watcher_remount (TrashWatcher *watcher)
|
||||
{
|
||||
int result;
|
||||
|
||||
- if (new && g_unix_mount_is_system_internal (new->data))
|
||||
+ if (new && ignore_trash_mount (new->data))
|
||||
{
|
||||
g_unix_mount_free (new->data);
|
||||
new = new->next;
|
||||
--
|
||||
2.41.0
|
||||
|
@ -0,0 +1,64 @@
|
||||
From 1c2cc7c0b80e5fc3f59e8557232bb6ff8ebbab7a Mon Sep 17 00:00:00 2001
|
||||
From: Ondrej Holy <oholy@redhat.com>
|
||||
Date: Fri, 12 Jul 2024 13:21:49 +0200
|
||||
Subject: [PATCH] trash: Add support for x-gvfs-trash mount option
|
||||
|
||||
Currently, the trash functionality is disabled for system internal mounts.
|
||||
That might be a problem in some cases. The `x-gvfs-notrash` mount option
|
||||
allows disabling the trash functionality for certain mounts. Let's add
|
||||
support for the `x-gvfs-trash` mount option to allow the opposite.
|
||||
|
||||
See: https://issues.redhat.com/browse/RHEL-46828
|
||||
|
||||
Related: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/4155
|
||||
---
|
||||
daemon/trashlib/trashwatcher.c | 22 +++++++++++++---------
|
||||
1 file changed, 13 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/daemon/trashlib/trashwatcher.c b/daemon/trashlib/trashwatcher.c
|
||||
index eec32d0b..707323cb 100644
|
||||
--- a/daemon/trashlib/trashwatcher.c
|
||||
+++ b/daemon/trashlib/trashwatcher.c
|
||||
@@ -218,10 +218,6 @@ ignore_trash_mount (GUnixMountEntry *mount)
|
||||
{
|
||||
GUnixMountPoint *mount_point = NULL;
|
||||
const gchar *mount_options;
|
||||
- gboolean retval = TRUE;
|
||||
-
|
||||
- if (g_unix_mount_is_system_internal (mount))
|
||||
- return TRUE;
|
||||
|
||||
mount_options = g_unix_mount_get_options (mount);
|
||||
if (mount_options == NULL)
|
||||
@@ -230,15 +226,23 @@ ignore_trash_mount (GUnixMountEntry *mount)
|
||||
NULL);
|
||||
if (mount_point != NULL)
|
||||
mount_options = g_unix_mount_point_get_options (mount_point);
|
||||
+
|
||||
+ g_clear_pointer (&mount_point, g_unix_mount_point_free);
|
||||
}
|
||||
|
||||
- if (mount_options == NULL ||
|
||||
- strstr (mount_options, "x-gvfs-notrash") == NULL)
|
||||
- retval = FALSE;
|
||||
+ if (mount_options != NULL)
|
||||
+ {
|
||||
+ if (strstr (mount_options, "x-gvfs-trash") != NULL)
|
||||
+ return FALSE;
|
||||
|
||||
- g_clear_pointer (&mount_point, g_unix_mount_point_free);
|
||||
+ if (strstr (mount_options, "x-gvfs-notrash") != NULL)
|
||||
+ return TRUE;
|
||||
+ }
|
||||
+
|
||||
+ if (g_unix_mount_is_system_internal (mount))
|
||||
+ return TRUE;
|
||||
|
||||
- return retval;
|
||||
+ return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
--
|
||||
2.46.1
|
||||
|
@ -0,0 +1,55 @@
|
||||
From 41862c0179f834d8bc3bd84ce78ee495050f2676 Mon Sep 17 00:00:00 2001
|
||||
From: rong wang <wangrong@uniontech.com>
|
||||
Date: Thu, 23 Mar 2023 10:26:24 +0800
|
||||
Subject: [PATCH] trash: Sync trash dir items when files change
|
||||
|
||||
In the case of an application monitoring the trash can, delete a file
|
||||
on the mounted device to the trash can, and then unmount the device.
|
||||
At this time, if you check the status of the trash can, you will find
|
||||
that the number of files queried is inconsistent with the number of
|
||||
files obtained through the enumeration job. This is because the number
|
||||
of files queried includes some files that do not exist when the device
|
||||
is unmounted. The solution is to synchronize the status of the trash
|
||||
can in time to ensure that the trash can does not record files that do
|
||||
not exist.
|
||||
---
|
||||
daemon/trashlib/trashdir.c | 21 +++++++++++++++++++--
|
||||
1 file changed, 19 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/daemon/trashlib/trashdir.c b/daemon/trashlib/trashdir.c
|
||||
index c470d3bd..0d7d2b1b 100644
|
||||
--- a/daemon/trashlib/trashdir.c
|
||||
+++ b/daemon/trashlib/trashdir.c
|
||||
@@ -163,10 +163,27 @@ 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->topdir, dir->is_homedir);
|
||||
+ {
|
||||
+ dir->items = g_slist_insert_sorted (dir->items,
|
||||
+ g_object_ref (file),
|
||||
+ (GCompareFunc) compare_basename);
|
||||
+ 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);
|
||||
+ {
|
||||
+ GSList *node;
|
||||
+
|
||||
+ node = g_slist_find_custom (dir->items,
|
||||
+ file,
|
||||
+ (GCompareFunc) compare_basename);
|
||||
+ if (node)
|
||||
+ {
|
||||
+ g_object_unref (node->data);
|
||||
+ dir->items = g_slist_delete_link (dir->items, node);
|
||||
+ }
|
||||
+ trash_root_remove_item (dir->root, file, dir->is_homedir);
|
||||
+ }
|
||||
|
||||
else if (event_type == G_FILE_MONITOR_EVENT_PRE_UNMOUNT ||
|
||||
event_type == G_FILE_MONITOR_EVENT_UNMOUNTED ||
|
||||
--
|
||||
2.41.0
|
||||
|
Loading…
Reference in new issue