From b716ef54b95d0d08d50203cf6614fda86cfd2afa Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 4 May 2021 03:37:23 +0100 Subject: [PATCH] bundles download: Use Namedfile Signed-off-by: Ian Jackson --- daemon/main.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/daemon/main.rs b/daemon/main.rs index 03a39249..54d9c5ad 100644 --- a/daemon/main.rs +++ b/daemon/main.rs @@ -247,12 +247,16 @@ fn bundle<'r>(instance: Parse, let ig = ig.by_ref(Authorisation::authorise_any()); ig.asset_url_key.check("bundle", &(instance, id), &token)? }.map(|(_,id)| id); - let f = id.open_by_name(instance, auth).map_err(IE::from)?; + let path = id.path(&ig, auth); + let f = match rocket::response::NamedFile::open(&path) { + Err(e) if e.kind() == ErrorKind::NotFound => throw!(BDE::NotFound), + Err(e) => throw!(IE::from(AE::from(e).context(path).context("bundle"))), + Ok(y) => y, + }; let ctype = match id.kind { bundles::Kind::Zip => ContentType::ZIP, }; - if_let!{ Some(f) = f; else throw!(BundleDownloadError::NotFound) } - Content(ctype, rocket::response::Stream::from(f)) + Content(ctype, f) } #[derive(Debug,Copy,Clone)] -- 2.30.2