diff options
author | Melody Horn <melody@boringcactus.com> | 2021-03-27 10:11:20 -0600 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2021-03-27 10:11:20 -0600 |
commit | e0f4483ff90e85b841a3cd4748811fcf3738d495 (patch) | |
tree | 92ab4c2ef8e1274dc06f19ffa5558ee8eeeb86bc /src/download.rs | |
parent | b5cb3fe9bafc4448b14335c9e0b9d90f1f7c78cb (diff) | |
download | webget-e0f4483ff90e85b841a3cd4748811fcf3738d495.tar.gz webget-e0f4483ff90e85b841a3cd4748811fcf3738d495.zip |
allow user to specify output directory
Diffstat (limited to 'src/download.rs')
-rw-r--r-- | src/download.rs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/download.rs b/src/download.rs index 72cdaf3..82bb302 100644 --- a/src/download.rs +++ b/src/download.rs @@ -14,6 +14,8 @@ use super::Args; type HttpsClient = Client<HttpsConnector<HttpConnector>>; pub(crate) async fn download(url: Uri, args: &Args) -> Result<(), Error> { + let output_file_dir = &args.directory_prefix; + let output_file_path = if let Some(output) = &args.output_document { Some(output.clone()) } else { @@ -49,6 +51,8 @@ pub(crate) async fn download(url: Uri, args: &Args) -> Result<(), Error> { PathBuf::from(format!("index{}", extension)) }; + let output_file_path = output_file_dir.join(output_file_path); + let mut output_file = fs::File::create(output_file_path).await?; while let Some(data) = response.body_mut().data().await { |