1
0
mirror of https://github.com/pcvolkmer/osc-variant.git synced 2025-07-03 01:02:55 +00:00

Add progress bar to OSB file check

This commit is contained in:
2023-11-09 12:11:13 +01:00
parent 774b57d78e
commit c9ecb8e944
3 changed files with 54 additions and 12 deletions

View File

@ -26,6 +26,8 @@ use std::fs;
use std::io::Read;
use std::path::Path;
use indicatif::ProgressBar;
use crate::checks::{osc, CheckNotice};
#[cfg(feature = "unzip-osb")]
@ -52,7 +54,10 @@ pub fn check_file(file: &Path, password: &str) -> Vec<CheckNotice> {
let mut result = vec![];
let progress_bar = ProgressBar::new(archive.len() as u64);
for i in 0..archive.len() {
progress_bar.inc(1);
if let Ok(Ok(mut zip_file)) = archive.by_index_decrypt(i, password.as_bytes()) {
if zip_file.is_file() && zip_file.name().ends_with(".osc") {
result.push(CheckNotice::Info {
@ -75,6 +80,7 @@ pub fn check_file(file: &Path, password: &str) -> Vec<CheckNotice> {
}];
}
}
progress_bar.finish_and_clear();
result
}