summaryrefslogtreecommitdiffstats
path: root/src/commands/source.rs
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-12-09 12:17:54 +0100
committerMatthias Beyer <mail@beyermatthias.de>2020-12-09 14:52:09 +0100
commit900719e3b89476c7134d0be4b3b90f1725671e2b (patch)
treea02f10c1ab69c6ce13082613772a1376a88b14a1 /src/commands/source.rs
parent58023aa2ac8078438db91b5cd0f15947cf65f9c9 (diff)
Add more log output in case of error when downloading sources
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/commands/source.rs')
-rw-r--r--src/commands/source.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/commands/source.rs b/src/commands/source.rs
index bbac6b6..4fd1d91 100644
--- a/src/commands/source.rs
+++ b/src/commands/source.rs
@@ -2,6 +2,7 @@ use std::io::Write;
use std::path::PathBuf;
use anyhow::Error;
+use anyhow::Context;
use anyhow::Result;
use anyhow::anyhow;
use clap::ArgMatches;
@@ -133,10 +134,14 @@ pub async fn download(matches: &ArgMatches, config: &Configuration, repo: Reposi
let _ = source.remove_file().await?;
}
- trace!("Starting download...");
- let file = source.create().await?;
+ trace!("Creating: {:?}", source);
+ let file = source.create().await
+ .with_context(|| anyhow!("Creating source file destination: {}", source.path().display()))?;
+
let mut file = tokio::io::BufWriter::new(file);
- let response = reqwest::get(source.url().as_ref()).await?;
+ let response = reqwest::get(source.url().as_ref()).await
+ .with_context(|| anyhow!("Downloading '{}'", source.url()))?;
+
if let Some(len) = response.content_length() {
bar.set_length(len);
}