summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2022-03-07 17:03:14 +0100
committerCanop <cano.petrole@gmail.com>2022-03-07 17:03:14 +0100
commitc2efd0444ecaba5fd592d7c5b5c5f3b4a61123d6 (patch)
tree99757bc5d0c2c450ac6d6db964b6aae5836699a0 /src
parenta4aac491fcbfaa35eabe4a8ce8666895b7ab94d4 (diff)
don't query size of remote volumes
This prevents a temporary hang when running broot with size option or in filesystem state if a remote volume is unreachable.
Diffstat (limited to 'src')
-rw-r--r--src/filesystems/filesystems_state.rs10
-rw-r--r--src/filesystems/mount_list.rs10
-rw-r--r--src/filesystems/mount_space_display.rs2
3 files changed, 16 insertions, 6 deletions
diff --git a/src/filesystems/filesystems_state.rs b/src/filesystems/filesystems_state.rs
index fd83857..903e909 100644
--- a/src/filesystems/filesystems_state.rs
+++ b/src/filesystems/filesystems_state.rs
@@ -66,7 +66,7 @@ impl FilesystemState {
if show_only_disks {
mount.disk.is_some()
} else {
- mount.stats.is_some()
+ mount.stats().is_some()
}
})
.cloned()
@@ -407,7 +407,7 @@ impl PanelState for FilesystemState {
cw.queue_char(border_style, '│')?;
}
// size, used, free
- if let Some(stats) = mount.stats.as_ref().filter(|s| s.size() > 0) {
+ if let Some(stats) = mount.stats().filter(|s| s.size() > 0) {
let share_color = super::share_color(stats.use_share());
// used
if e_use {
@@ -430,7 +430,11 @@ impl PanelState for FilesystemState {
cw.queue_g_string(&share_style, format!("{:>4}", file_size::fit_4(stats.available())))?;
cw.queue_char(border_style, '│')?;
// size
- cw.queue_g_string(txt_style, format!("{:>4}", file_size::fit_4(mount.size())))?;
+ if let Some(stats) = mount.stats() {
+ cw.queue_g_string(txt_style, format!("{:>4}", file_size::fit_4(stats.size())))?;
+ } else {
+ cw.repeat(txt_style, &SPACE_FILLING, 4)?;
+ }
cw.queue_char(border_style, '│')?;
} else {
// used
diff --git a/src/filesystems/mount_list.rs b/src/filesystems/mount_list.rs
index cad0e7c..03e044e 100644
--- a/src/filesystems/mount_list.rs
+++ b/src/filesystems/mount_list.rs
@@ -7,6 +7,7 @@ use {
DeviceId,
Mount,
read_mounts,
+ ReadOptions,
},
};
@@ -24,10 +25,15 @@ impl MountList {
/// try to load the mounts if they aren't loaded.
pub fn load(&mut self) -> Result<&Vec<Mount>, ProgramError> {
if self.mounts.is_none() {
- match read_mounts() {
+ let mut options = ReadOptions::default();
+ options.remote_stats(false);
+ match read_mounts(&options) {
Ok(mut vec) => {
debug!("{} mounts loaded", vec.len());
- vec.sort_by_key(|m| u64::MAX - m.size());
+ vec.sort_by_key(|m| {
+ let size = m.stats().map_or(0, |s| s.size());
+ u64::MAX - size
+ });
self.mounts = Some(vec);
}
Err(e) => {
diff --git a/src/filesystems/mount_space_display.rs b/src/filesystems/mount_space_display.rs
index 13871d7..0570c6e 100644
--- a/src/filesystems/mount_space_display.rs
+++ b/src/filesystems/mount_space_display.rs
@@ -48,7 +48,7 @@ impl<'m, 's> MountSpaceDisplay<'m, 's> {
};
cond_bg!(txt_style, self, selected, self.skin.default);
let w_fs = self.mount.info.fs.chars().count();
- if let Some(s) = &self.mount.stats {
+ if let Some(s) = &self.mount.stats() {
//- width computation
let mut e_fs = false;
let dsk = self.mount.disk.as_ref().map_or("", |d| d.disk_type());