Disambiguate mount points with same name on "Low Disk Space" notifications

When there's more than one mount point with the same name, we show the
mount path instead.

Related: RHEL-11910
This commit is contained in:
Felipe Borges 2025-01-15 15:53:42 +01:00 committed by Felipe Borges
parent 2482e2e665
commit ac1cc3aa1f
2 changed files with 79 additions and 1 deletions

View File

@ -11,7 +11,7 @@
Name: gnome-settings-daemon
Version: 40.0.1
Release: 21%{?dist}
Release: 22%{?dist}
Summary: The daemon sharing settings from GNOME to GTK+/KDE applications
License: GPLv2+
@ -82,6 +82,9 @@ Patch00009: subman-launch-registration-dialog-directly.patch
# https://issues.redhat.com/browse/RHEL-4092
Patch00010: subman-build-option.patch
# https://issues.redhat.com/browse/RHEL-11910
Patch00011: housekeeping-disambiguate-mount-names-in-notifications.patch
%description
A daemon to share settings from GNOME to other applications. It also
handles global keybindings, as well as a number of desktop-wide settings.
@ -206,6 +209,10 @@ cp %{SOURCE1} $RPM_BUILD_ROOT%{_datadir}/glib-2.0/schemas
%{_libdir}/pkgconfig/gnome-settings-daemon.pc
%changelog
* Tue Mar 04 2025 Felipe Borges <feborges@redhat.com> - 40.0.1-22
- Use mount path in "Low disk" notification when multiple mount points have same name
Related: RHEL-11910
* Thu Feb 27 2025 Felipe Borges <feborges@redhat.com> - 40.0.1-21
- Add build option to disable subman plugin
Related: RHEL-4092

View File

@ -0,0 +1,71 @@
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