From 25fd5aeb2aba5d5390fdc4238404b71a73a30963 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 20 Jan 2021 15:45:05 +0100 Subject: Add MergedStores::get_artifact_by_path() Signed-off-by: Matthias Beyer --- src/filestore/merged.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src') diff --git a/src/filestore/merged.rs b/src/filestore/merged.rs index ec57501..d1bcfe7 100644 --- a/src/filestore/merged.rs +++ b/src/filestore/merged.rs @@ -79,4 +79,29 @@ impl MergedStores { Ok(v) } } + + pub async fn get_artifact_by_path(&self, p: &Path) -> Result> { + let artifact_path = ArtifactPath::new(p.to_path_buf())?; + + let staging = &mut self.staging.write().await.0; + let staging_path = staging.root_path().join(&artifact_path)?; + + if staging_path.exists() { + let art_path = ArtifactPath::new(p.to_path_buf())?; + let art = staging.load_from_path(&artifact_path)?; + return Ok(Some(art.clone())) + } + + drop(staging); + + let release = &mut self.release.write().await.0; + let release_path = release.root_path().join(&artifact_path)?; + + if release_path.exists() { + let art = release.load_from_path(&artifact_path)?; + return Ok(Some(art.clone())) + } + + Ok(None) + } } -- cgit v1.2.3