Print human readable file size to log
This commit is contained in:
parent
db2e73aa8e
commit
1169ef4536
7
Cargo.lock
generated
7
Cargo.lock
generated
@ -752,6 +752,12 @@ version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "05842d0d43232b23ccb7060ecb0f0626922c21f30012e97b767b30afd4a5d4b9"
|
||||
|
||||
[[package]]
|
||||
name = "humansize"
|
||||
version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "02296996cb8796d7c6e3bc2d9211b7802812d36999a51bb754123ead7d37d026"
|
||||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "0.14.7"
|
||||
@ -995,6 +1001,7 @@ dependencies = [
|
||||
"compress-tools",
|
||||
"dotenv",
|
||||
"futures",
|
||||
"humansize",
|
||||
"infer",
|
||||
"reqwest",
|
||||
"scraper",
|
||||
|
@ -14,6 +14,7 @@ chrono = { version = "0.4", features = ["serde"] }
|
||||
compress-tools = "0.12"
|
||||
dotenv = "0.15"
|
||||
futures = "0.3"
|
||||
humansize = "1.1"
|
||||
infer = { version = "0.4", default-features = false }
|
||||
reqwest = { version = "0.11", features = ["json", "stream"] }
|
||||
scraper = "0.12"
|
||||
|
@ -1,6 +1,7 @@
|
||||
use anyhow::Result;
|
||||
use argh::FromArgs;
|
||||
use dotenv::dotenv;
|
||||
use humansize::{FileSize, file_size_opts};
|
||||
use models::file::File;
|
||||
use models::game_mod::Mod;
|
||||
use reqwest::StatusCode;
|
||||
@ -275,7 +276,7 @@ pub async fn main() -> Result<()> {
|
||||
|
||||
for api_file in files {
|
||||
let file_span =
|
||||
info_span!("file", name = &api_file.file_name, id = &api_file.file_id);
|
||||
info_span!("file", name = &api_file.file_name, id = &api_file.file_id,);
|
||||
let _file_span = file_span.enter();
|
||||
|
||||
if processed_file_ids.contains(&(api_file.file_id as i32)) {
|
||||
@ -315,6 +316,9 @@ pub async fn main() -> Result<()> {
|
||||
}
|
||||
};
|
||||
|
||||
let humanized_size = api_file.size.file_size(file_size_opts::CONVENTIONAL)
|
||||
.expect("unable to create human-readable file size");
|
||||
info!(size = %humanized_size, "decided to download file");
|
||||
let download_link_resp =
|
||||
nexus_api::download_link::get(&client, db_mod.nexus_mod_id, api_file.file_id)
|
||||
.await;
|
||||
|
Loading…
Reference in New Issue
Block a user