From ae3bf27d0e06cc1f3b1f95c873ec39fb9c01d0f0 Mon Sep 17 00:00:00 2001 From: timvisee Date: Wed, 28 Mar 2018 00:25:28 +0200 Subject: [PATCH] Print the path in file usage errors --- api/src/action/download.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/api/src/action/download.rs b/api/src/action/download.rs index 9f27ad5..dcc8c4a 100644 --- a/api/src/action/download.rs +++ b/api/src/action/download.rs @@ -61,8 +61,9 @@ impl<'a> Download<'a> { // Open the file we will write to // TODO: this should become a temporary file first // TODO: use the uploaded file name as default - let out = File::create("downloaded.zip") - .map_err(|err| Error::File(FileError::Create(err)))?; + let path = "downloaded.zip"; + let out = File::create(path) + .map_err(|err| Error::File(path.into(), FileError::Create(err)))?; // Create the file reader for downloading let (reader, len) = self.create_file_reader(&key, meta_nonce, &client) @@ -74,7 +75,7 @@ impl<'a> Download<'a> { len, &key, reporter.clone(), - ).map_err(|err| Error::File(err))?; + ).map_err(|err| Error::File(path.into(), err))?; // Download the file self.download(reader, writer, len, reporter) @@ -361,8 +362,8 @@ pub enum Error { /// An error occurred while opening or writing to the target file. // TODO: show what file this is about - #[fail(display = "Couldn't use the target file")] - File(#[cause] FileError), + #[fail(display = "Couldn't use the target file at '{}'", _0)] + File(String, #[cause] FileError), } impl From for Error {