From 8641500bef852b7bee3341ce2fde4a8947fe362d Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Tue, 7 Mar 2023 13:23:26 +0100 Subject: location-list: Make available space more accurate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On ext4 filesystem, 5% of space is reserved by default (i.e. ~100 GiB for a 2 TiB drive). Let’s make use of the `filesystem::free` attribute when available, it is also what Nautilus uses. This was exposed separately in the past but removed in https://gitlab.gnome.org/GNOME/baobab/-/commit/f8501c44c89cae1fe40228de2ca24ec9efe4822d --- src/baobab-location-list.vala | 5 +++-- src/baobab-location.vala | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/baobab-location-list.vala b/src/baobab-location-list.vala index 731e329..651c719 100644 --- a/src/baobab-location-list.vala +++ b/src/baobab-location-list.vala @@ -68,13 +68,14 @@ namespace Baobab { total_size_label.show(); if (location.used != null) { - available_label.label = _("%s Available").printf (format_size (location.size - location.used)); + var actually_used = location.used + (location.reserved ?? 0); + available_label.label = _("%s Available").printf (format_size (location.size - actually_used)); usage_bar.max_value = location.size; // Set critical color at 90% of the size usage_bar.add_offset_value (Gtk.LEVEL_BAR_OFFSET_LOW, 0.9 * location.size); - usage_bar.value = location.used; + usage_bar.value = actually_used; usage_bar.show (); } else { available_label.label = _("Unknown"); diff --git a/src/baobab-location.vala b/src/baobab-location.vala index 4954e57..78c138c 100644 --- a/src/baobab-location.vala +++ b/src/baobab-location.vala @@ -53,7 +53,8 @@ namespace Baobab { private const string FS_ATTRIBUTES = FileAttribute.FILESYSTEM_SIZE + "," + - FileAttribute.FILESYSTEM_USED; + FileAttribute.FILESYSTEM_USED + "," + + FileAttribute.FILESYSTEM_FREE; string get_hostname () throws Error { HostnameIface hostname_iface; -- cgit v1.2.1