weird /proc/<number>/smaps_rollup error

This commit is contained in:
benstrb 2026-01-30 22:05:11 +01:00
parent 2dcb49dd80
commit 4f82deac1a

View file

@ -237,7 +237,7 @@ impl PreviewWidget<'_> {
} }
fn not_a_dir(&mut self, absolute_path: &PathBuf) { fn not_a_dir(&mut self, absolute_path: &PathBuf) {
match absolute_path.is_file() { match absolute_path.exists() && absolute_path.is_file() {
true => { true => {
let block = Block::new() let block = Block::new()
.borders(Borders::ALL) .borders(Borders::ALL)
@ -254,7 +254,11 @@ impl PreviewWidget<'_> {
self.invalid_data(); self.invalid_data();
} }
ErrorKind::PermissionDenied => self.permission_denied(), ErrorKind::PermissionDenied => self.permission_denied(),
_ => panic!("Problem with reading the contents of the file:\n{err:?}"), _ => {
self.list = List::new(vec!["Cannot read file"])
.block(block)
.style(Color::Red)
}
}, },
} }
} }
@ -264,11 +268,15 @@ impl PreviewWidget<'_> {
.padding(Padding::symmetric(1, 1)) .padding(Padding::symmetric(1, 1))
.fg(Color::Blue); .fg(Color::Blue);
self.list = List::new(vec![ if absolute_path.exists() {
"This is neither a directory or a file\nI have no idea what to do with this", self.list = List::new(vec!["This is neither a directory\nOr a file"])
]) .block(block)
.block(block) .style(Color::Red)
.style(Color::Red) } else {
self.list = List::new(vec!["This file does not exist anymore"])
.block(block)
.style(Color::Red)
}
} }
} }
} }