Filenames no longer contain URL params

- Fixes #12
This commit is contained in:
Daniel M 2021-03-28 03:11:02 +02:00
parent 833af6e8d3
commit bc84eb1c2a
2 changed files with 6 additions and 1 deletions

View File

@ -54,7 +54,8 @@ impl RollingAverage {
pub fn url_to_filename(url: &str) -> String { pub fn url_to_filename(url: &str) -> String {
let url_dec = percent_decode_str(&url).decode_utf8_lossy().to_owned().to_string(); let url_dec = percent_decode_str(&url).decode_utf8_lossy().to_owned().to_string();
let file_name = std::path::Path::new(&url_dec).file_name().unwrap().to_str().unwrap(); let file_name = std::path::Path::new(&url_dec).file_name().unwrap().to_str().unwrap();
file_name.to_string() // Split at ? and return the first part. If no ? is present, this just returns the full string
file_name.split("?").next().unwrap().to_string()
} }
pub async fn download_feedback(url: &str, into_file: &str, rep: DlReporter) -> ResBE<()> { pub async fn download_feedback(url: &str, into_file: &str, rep: DlReporter) -> ResBE<()> {

View File

@ -4,6 +4,7 @@ use clap::{ App, Arg, ArgGroup, crate_version };
use tokio::sync::mpsc; use tokio::sync::mpsc;
use futures::future::join_all; use futures::future::join_all;
use std::io::BufRead; use std::io::BufRead;
use std::time::SystemTime;
use dlreport::{ DlReport, DlStatus, DlReporter }; use dlreport::{ DlReport, DlStatus, DlReporter };
use errors::ResBE; use errors::ResBE;
@ -179,6 +180,8 @@ async fn download_multiple(urls: Vec<String>, outdir: &str, numparal: i32, boost
std::fs::create_dir_all(outdir)?; std::fs::create_dir_all(outdir)?;
} }
let t_start = SystemTime::now();
let mut joiners = Vec::new(); let mut joiners = Vec::new();
let (tx, rx) = mpsc::unbounded_channel::<DlReport>(); let (tx, rx) = mpsc::unbounded_channel::<DlReport>();
@ -265,6 +268,7 @@ async fn download_multiple(urls: Vec<String>, outdir: &str, numparal: i32, boost
join_all(joiners).await; join_all(joiners).await;
println!("Total time: {}s", t_start.elapsed()?.as_secs());
Ok(()) Ok(())
} }