summaryrefslogtreecommitdiffstats
path: root/src/filestore/staging.rs
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-12-07 13:31:35 +0100
committerMatthias Beyer <mail@beyermatthias.de>2020-12-07 13:31:35 +0100
commit34ce17e2e90426acf6f5677da4ff1bec2288e98c (patch)
tree556609e3b0f10455c268a1f5fb07515639bc1a1e /src/filestore/staging.rs
parent40f8002ea95659698cd328753ac7c98c79a8ba03 (diff)
Add runtime check in ArtifactPath::new
This adds a runtime check whether the artifact path is indeed relative. An absolute artifact path is a bug. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/filestore/staging.rs')
-rw-r--r--src/filestore/staging.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/filestore/staging.rs b/src/filestore/staging.rs
index df7e006..93c4047 100644
--- a/src/filestore/staging.rs
+++ b/src/filestore/staging.rs
@@ -70,12 +70,14 @@ impl StagingStore {
None
} else {
Some({
- let path = ArtifactPath::new(path);
- self.0.load_from_path(&path)
- .inspect(|r| trace!("Loaded from path {} = {:?}", path.display(), r))
- .with_context(|| anyhow!("Loading from path: {}", path.display()))
- .map_err(Error::from)
- .map(|art| art.path().clone())
+ ArtifactPath::new(path)
+ .and_then(|ap| {
+ self.0.load_from_path(&ap)
+ .inspect(|r| trace!("Loaded from path {} = {:?}", ap.display(), r))
+ .with_context(|| anyhow!("Loading from path: {}", ap.display()))
+ .map_err(Error::from)
+ .map(|art| art.path().clone())
+ })
})
}
})