mirror of
https://github.com/jht5945/finding.git
synced 2025-12-29 14:10:05 +08:00
update hugefile logic
This commit is contained in:
20
src/main.rs
20
src/main.rs
@@ -46,15 +46,26 @@ fn main() {
|
|||||||
};
|
};
|
||||||
match target.as_str() {
|
match target.as_str() {
|
||||||
"huge" | "hugefile" => {
|
"huge" | "hugefile" => {
|
||||||
|
let huge_file_size_bytes = match parse_size(&huge_file_size) {
|
||||||
|
Err(err) => {
|
||||||
|
print_message(MessageType::ERROR, &format!("Parse size failed: {}", err));
|
||||||
|
return;
|
||||||
|
},
|
||||||
|
Ok(bytes) => bytes as u64,
|
||||||
|
};
|
||||||
walk_dir(&dir_path, &|_, _| () /* do not process error */, &|p| {
|
walk_dir(&dir_path, &|_, _| () /* do not process error */, &|p| {
|
||||||
match p.metadata() {
|
match p.metadata() {
|
||||||
Err(_) => (),
|
Err(_) => (),
|
||||||
Ok(metadata) => {
|
Ok(metadata) => {
|
||||||
let len = metadata.len();
|
let len = metadata.len();
|
||||||
if len > 100 * 1024 * 1024 {
|
if len >= huge_file_size_bytes {
|
||||||
print_lastline("");
|
match p.to_str() {
|
||||||
//println!();
|
None => (),
|
||||||
print_message(MessageType::OK, &format!("{:?}: {}", p, get_display_size(len as i64)));
|
Some(p_str) => {
|
||||||
|
print_lastline("");
|
||||||
|
print_message(MessageType::OK, &format!("{} [{}]", p_str, get_display_size(len as i64)));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -65,6 +76,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
true
|
true
|
||||||
}).unwrap_or(());
|
}).unwrap_or(());
|
||||||
|
print_lastline("");
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
_ => (),
|
_ => (),
|
||||||
|
|||||||
Reference in New Issue
Block a user