Compare commits

...

2 Commits

Author SHA1 Message Date
9d976b49ab Actually fix the parallel download 2022-04-01 01:22:13 +02:00
3e7601db1d Fix parallel file downloads not working 2022-04-01 01:09:37 +02:00

View File

@ -109,13 +109,17 @@ async fn download_multiple(args: CLIArgs, raw_urls: Vec<String>) -> Result<()> {
}
async fn download_job(urls: SyncQueue, reporter: UnboundedSender<DlReport>, cli_args: CLIArgs) {
while let Some(dlreq) = urls.lock().await.pop_front() {
// The mutex access must be in its own scope to ensure that the lock is dropped
while let Some(dlreq) = {
let mut urls = urls.lock().await;
urls.pop_front().take()
} {
println!("Downloading {}", dlreq.url);
let reporter = DlReporter::new(dlreq.id as u32, reporter.clone());
// Resolve the zippy url to the direct download url if necessary
let url = match is_integrated_url(&dlreq.url) {
Some(service) => {
match resolve_integrated_url(&dlreq.url, service).await {
Some(service) => match resolve_integrated_url(&dlreq.url, service).await {
Ok(url) => url,
Err(_e) => {
report_msg!(
@ -125,8 +129,7 @@ async fn download_job(urls: SyncQueue, reporter: UnboundedSender<DlReport>, cli_
);
continue;
}
}
}
},
None => dlreq.url,
};