Skip to content

Commit

Permalink
store-histogram: skip not found file meta (#2906)
Browse files Browse the repository at this point in the history
* add error message to show th filename when the file not fund

* Update accounts-db/store-histogram/src/main.rs

Co-authored-by: Brooks <brooks@prumo.org>

* fmt

* skip when meatadata fails

---------

Co-authored-by: HaoranYi <haoran.yi@anza.xyz>
Co-authored-by: Brooks <brooks@prumo.org>
  • Loading branch information
3 people committed Sep 18, 2024
1 parent cfd3936 commit 92eca11
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions accounts-db/store-histogram/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,16 @@ fn main() {
for entry in dir.flatten() {
if let Some(name) = entry.path().file_name() {
let name = name.to_str().unwrap().split_once(".").unwrap().0;
let len = fs::metadata(entry.path()).unwrap().len();
info.push((name.parse::<usize>().unwrap(), len as usize));
match fs::metadata(entry.path()) {
Ok(meta) => {
info.push((name.parse::<usize>().unwrap(), meta.len() as usize));
}
Err(_) => {
// skip when metadata fails. This can happen when you are running this tool while a validator is running.
// It could clean something away and delete it after getting the dir but before opening the file.
continue;
}
}
// eprintln!("{name}, {len}");
}
}
Expand Down

0 comments on commit 92eca11

Please sign in to comment.