From 10708b6570fdbf7fa05b806271d7937ea5cbc5d1 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 4 May 2021 03:28:32 +0100 Subject: [PATCH] bundles download: Provide a path() more useful for download Signed-off-by: Ian Jackson --- src/bundles.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/bundles.rs b/src/bundles.rs index f4ed31fd..7ead949b 100644 --- a/src/bundles.rs +++ b/src/bundles.rs @@ -201,14 +201,19 @@ impl Id { b_file(instance, self.index, "tmp") } - fn path(&self, instance: &InstanceName) -> String { + fn path_(&self, instance: &InstanceName) -> String { b_file(instance, self.index, self.kind) } + pub fn path(&self, instance: &Unauthorised, InstanceName>, + auth: Authorisation) -> String { + self.path_(&instance.by_ref(auth.therefore_ok()).name) + } + #[throws(IE)] pub fn open_by_name(&self, instance_name: &InstanceName, _: Authorisation) -> Option { - let path = self.path(instance_name); + let path = self.path_(instance_name); match File::open(&path) { Ok(f) => Some(f), Err(e) if e.kind() == ErrorKind::NotFound => None, @@ -453,7 +458,7 @@ impl InstanceBundles { expected: &Hash) { let (hash, mut file) = file.finish(); let tmp = id.path_tmp(&ig.name); - let install = id.path(&ig.name); + let install = id.path_(&ig.name); file.flush() .with_context(|| tmp.clone()).context("flush").map_err(IE::from)?; if hash.as_slice() != &expected.0[..] { throw!(ME::UploadCorrupted) } -- 2.30.2