From eb6ebb70cdd276f812e480d84d82a1033f396d4a Mon Sep 17 00:00:00 2001 From: Levi Zim Date: Fri, 30 Aug 2024 23:03:03 +0800 Subject: [PATCH] fix(about): deduplicate disks when calc disk capacity --- pages/system/src/about.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pages/system/src/about.rs b/pages/system/src/about.rs index 8d8762c..fb4542d 100644 --- a/pages/system/src/about.rs +++ b/pages/system/src/about.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: GPL-3.0-only use bumpalo::Bump; -use std::{ffi::OsStr, io::Read}; +use std::{collections::HashSet, ffi::OsStr, io::Read}; use concat_in_place::strcat; use const_format::concatcp; @@ -53,7 +53,12 @@ impl Info { sys.refresh_memory(); let mut total_capacity = 0; + let mut disk_set = HashSet::new(); for disk in disks.list() { + if disk_set.contains(disk.name()) { + continue; + } + disk_set.insert(disk.name()); total_capacity += disk.total_space(); }