From 3a3ef00464117e34d0bd30fac927ac52b052ef07 Mon Sep 17 00:00:00 2001 From: Aleksei Nikiforov 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 #include #include +#include namespace Filelight { @@ -52,7 +53,7 @@ struct Disk }; -struct DiskList : QList +struct DiskList : QMap { 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 ignoredFsTypes = { "tmpfs", "squashfs" }; - - QStringList partitions; + static const QSet 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