Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37588175
en ru br
ALT Linux repos
S:23.04.3-alt1

Group :: Graphical desktop/KDE
RPM: kde5-filelight

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

Patch: alt-filter-out-duplicate-paths.patch
Download


From 3a3ef00464117e34d0bd30fac927ac52b052ef07 Mon Sep 17 00:00:00 2001
From: Aleksei Nikiforov <darktemplar@altlinux.org>
Date: Thu, 27 Feb 2020 17:30:13 +0300
Subject: [PATCH] Filelight: filter out duplicate paths
Sometimes, one mount path may be encountered multiple times
in /proc/self/mounts file.
For example, when systemd automounting is used.
In such cases Filelight would display such mount paths multiple times
in main window.
Or when multiple filesystems are mounted over same path.
In such cases use information only about last mounted filesystem
since only it is available at the moment.
Also ignore 'autofs' filesystems.
---
 filelight/src/summaryWidget.cpp | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/filelight/src/summaryWidget.cpp b/filelight/src/summaryWidget.cpp
index 637f7af..852d9ff 100644
--- a/filelight/src/summaryWidget.cpp
+++ b/filelight/src/summaryWidget.cpp
@@ -37,6 +37,7 @@
 #include <QMouseEvent>
 #include <QLayout>
 #include <QStorageInfo>
+#include <QMap>
 
 namespace Filelight
 {
@@ -52,7 +53,7 @@ struct Disk
 };
 
 
-struct DiskList : QList<Disk>
+struct DiskList : QMap<QString, Disk>
 {
     DiskList();
 };
@@ -107,7 +108,7 @@ void SummaryWidget::createDiskMaps()
 
     for (DiskList::ConstIterator it = disks.constBegin(), end = disks.constEnd(); it != end; ++it)
     {
-        Disk const &disk = *it;
+        Disk const &disk = it.value();
 
         if (disk.free == 0 && disk.used == 0)
             continue;
@@ -150,9 +151,7 @@ void SummaryWidget::createDiskMaps()
 
 DiskList::DiskList()
 {
-    static const QSet<QByteArray> ignoredFsTypes = { "tmpfs", "squashfs" };
-
-    QStringList partitions;
+    static const QSet<QByteArray> ignoredFsTypes = { "tmpfs", "squashfs", "autofs" };
 
     for (const QStorageInfo &storage : QStorageInfo::mountedVolumes()) {
         if (!storage.isReady() || ignoredFsTypes.contains(storage.fileSystemType())) {
@@ -166,7 +165,8 @@ DiskList::DiskList()
         disk.free = storage.bytesFree();
         disk.used = disk.size - disk.free;
 
-        *this += disk;
+        // if something is mounted over same path, last mounted point would be used since only it is currently reachable.
+        (*this)[disk.mount] = disk;
     }
 }
 
-- 
2.24.1
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin