From 900719e3b89476c7134d0be4b3b90f1725671e2b Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 9 Dec 2020 12:17:54 +0100 Subject: Add more log output in case of error when downloading sources Signed-off-by: Matthias Beyer --- src/commands/source.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/commands/source.rs') 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); } -- cgit v1.2.3