gnome-settings-daemon/housekeeping-disambiguate-mount-names-in-notifications.patch

72 lines
2.8 KiB
Diff
Raw Normal View History

From 0d6208bfaceaa9f27d30ff0f38e3accf7bd56f95 Mon Sep 17 00:00:00 2001
From: Felipe Borges <felipeborges@gnome.org>
Date: Wed, 15 Jan 2025 15:26:19 +0100
Subject: [PATCH] housekeeping: Disambiguate mount point names in notifications
There might be mount-points with same name, so when that's the case,
let's show the path instead.
Related: RHEL-11910
---
plugins/housekeeping/gsd-disk-space.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/plugins/housekeeping/gsd-disk-space.c b/plugins/housekeeping/gsd-disk-space.c
index c5ae8f6b..aff85205 100644
--- a/plugins/housekeeping/gsd-disk-space.c
+++ b/plugins/housekeeping/gsd-disk-space.c
@@ -670,7 +670,8 @@ ldsm_notify (const char *summary,
static void
ldsm_notify_for_mount (LdsmMountInfo *mount,
- gboolean multiple_volumes)
+ gboolean multiple_volumes,
+ gboolean is_ambiguous_name)
{
gboolean has_trash;
gchar *name;
@@ -688,7 +689,7 @@ ldsm_notify_for_mount (LdsmMountInfo *mount,
free_space_str = g_format_size (free_space);
if (multiple_volumes) {
- summary = g_strdup_printf (_("Low Disk Space on “%s”"), name);
+ summary = g_strdup_printf (_("Low Disk Space on “%s”"), is_ambiguous_name ? path : name);
if (has_trash) {
body = g_strdup_printf (_("The volume “%s” has only %s disk space remaining. You may free up some space by emptying the trash."),
name,
@@ -778,8 +779,10 @@ ldsm_maybe_warn_mounts (GList *mounts,
gboolean multiple_volumes)
{
GList *l;
+ GHashTable *mount_names;
gboolean done = FALSE;
+ mount_names = g_hash_table_new (g_str_hash, g_str_equal);
for (l = mounts; l != NULL; l = l->next) {
LdsmMountInfo *mount_info = l->data;
LdsmMountInfo *previous_mount_info;
@@ -832,10 +835,19 @@ ldsm_maybe_warn_mounts (GList *mounts,
}
if (show_notify) {
- ldsm_notify_for_mount (mount_info, multiple_volumes);
+ g_autofree gchar *mount_name = NULL;
+ gboolean is_ambiguous_name = FALSE;
+
+ mount_name = g_unix_mount_guess_name (mount_info->mount);
+ is_ambiguous_name = g_hash_table_contains (mount_names, mount_name);
+ g_hash_table_add (mount_names, mount_name);
+
+ ldsm_notify_for_mount (mount_info, multiple_volumes, is_ambiguous_name);
done = TRUE;
}
}
+
+ g_hash_table_destroy (mount_names);
}
static gboolean
--
2.37.1