summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-01-20 15:45:05 +0100
committerMatthias Beyer <matthias.beyer@atos.net>2021-01-21 14:54:50 +0100
commit25fd5aeb2aba5d5390fdc4238404b71a73a30963 (patch)
treeb42919c61e4ae9f2851f406911f6f6166e5d3e6b /src
parent4c697a9aa305bdab52c538944d1beff927a23d95 (diff)
Add MergedStores::get_artifact_by_path()
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
Diffstat (limited to 'src')
-rw-r--r--src/filestore/merged.rs25
1 files changed, 25 insertions, 0 deletions
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<Option<Artifact>> {
+ 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)
+ }
}