mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 12:12:00 -06:00
Merge branch 'master' into fix/rework-download
This commit is contained in:
commit
83bd71916c
2 changed files with 13 additions and 3 deletions
|
|
@ -75,8 +75,9 @@ impl CliLogger {
|
||||||
// replace the 'progress' prefix if this function is invoked via 'progress!'
|
// replace the 'progress' prefix if this function is invoked via 'progress!'
|
||||||
record
|
record
|
||||||
.target()
|
.target()
|
||||||
.replacen("progress", "crunchy_cli", 1)
|
.replacen("crunchy_cli_core", "crunchy_cli", 1)
|
||||||
.replacen("progress_end", "crunchy_cli", 1),
|
.replacen("progress_end", "crunchy_cli", 1)
|
||||||
|
.replacen("progress", "crunchy_cli", 1),
|
||||||
format!("{:?}", thread::current().id())
|
format!("{:?}", thread::current().id())
|
||||||
.replace("ThreadId(", "")
|
.replace("ThreadId(", "")
|
||||||
.replace(')', ""),
|
.replace(')', ""),
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@ pub async fn download_segments(
|
||||||
let thread_client = client.clone();
|
let thread_client = client.clone();
|
||||||
let thread_sender = sender.clone();
|
let thread_sender = sender.clone();
|
||||||
let thread_segments = segs.remove(0);
|
let thread_segments = segs.remove(0);
|
||||||
|
let thread_count = count.clone();
|
||||||
join_set.spawn(async move {
|
join_set.spawn(async move {
|
||||||
let after_download_sender = thread_sender.clone();
|
let after_download_sender = thread_sender.clone();
|
||||||
|
|
||||||
|
|
@ -108,16 +109,24 @@ pub async fn download_segments(
|
||||||
};
|
};
|
||||||
|
|
||||||
buf = VariantSegment::decrypt(buf.borrow_mut(), segment.key)?.to_vec();
|
buf = VariantSegment::decrypt(buf.borrow_mut(), segment.key)?.to_vec();
|
||||||
|
|
||||||
|
let mut c = thread_count.lock().unwrap();
|
||||||
debug!(
|
debug!(
|
||||||
"Downloaded and decrypted segment {} ({})",
|
"Downloaded and decrypted segment [{}/{} {:.2}%] {}",
|
||||||
num + (i * cpus),
|
num + (i * cpus),
|
||||||
|
total_segments,
|
||||||
|
((*c + 1) as f64 / total_segments as f64) * 100f64,
|
||||||
segment.url
|
segment.url
|
||||||
);
|
);
|
||||||
|
|
||||||
thread_sender.send((num as i32 + (i * cpus) as i32, buf))?;
|
thread_sender.send((num as i32 + (i * cpus) as i32, buf))?;
|
||||||
|
|
||||||
|
*c += 1;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
let result = download().await;
|
let result = download().await;
|
||||||
if result.is_err() {
|
if result.is_err() {
|
||||||
after_download_sender.send((-1 as i32, vec![]))?;
|
after_download_sender.send((-1 as i32, vec![]))?;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue