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) {
match absolute_path.is_file() {
match absolute_path.exists() && absolute_path.is_file() {
true => {
let block = Block::new()
.borders(Borders::ALL)
@ -254,7 +254,11 @@ impl PreviewWidget<'_> {
self.invalid_data();
}
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))
.fg(Color::Blue);
self.list = List::new(vec![
"This is neither a directory or a file\nI have no idea what to do with this",
])
if absolute_path.exists() {
self.list = List::new(vec!["This is neither a directory\nOr a file"])
.block(block)
.style(Color::Red)
} else {
self.list = List::new(vec!["This file does not exist anymore"])
.block(block)
.style(Color::Red)
}
}
}
}