From: Ian Jackson Date: Tue, 4 May 2021 02:28:32 +0000 (+0100) Subject: bundles download: Provide a path() more useful for download X-Git-Tag: otter-0.6.0~392 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=10708b6570fdbf7fa05b806271d7937ea5cbc5d1;p=otter.git bundles download: Provide a path() more useful for download Signed-off-by: Ian Jackson --- 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) }