Skip to content

Commit

Permalink
add import snapshot file lines num check (starcoinorg#3545)
Browse files Browse the repository at this point in the history
* add import snapshot file lines num check

* use Iterator count method
  • Loading branch information
nkysg authored and jiangying000 committed Jul 22, 2022
1 parent aaab088 commit 393d758
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cmd/db-exporter/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,16 @@ pub fn apply_snapshot(
}
file_list.push((column, nums, verify_hash));
}

for (file_name, nums, _) in file_list.iter() {
let file = BufReader::new(File::open(input_path.join(file_name))?);
let cnt = file.lines().count();
if cnt as BlockNumber != *nums {
println!("file {} line nums {} not equal {}", file_name, cnt, *nums);
std::process::exit(2);
}
}

let mbar = MultiProgress::new();
for item in file_list.iter().take(file_list.len() - 1) {
let (column, nums, verify_hash) = item.clone();
Expand Down

0 comments on commit 393d758

Please sign in to comment.