summaryrefslogtreecommitdiffstats
path: root/src/filestore/staging.rs
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-02-07 12:35:33 +0100
committerMatthias Beyer <mail@beyermatthias.de>2021-02-08 09:37:04 +0100
commitd319579fc89b5ac09f10abf4bfc77c21b0fc65ce (patch)
treee4fb352f3c1cd98383955d08c20fc0d311db51b7 /src/filestore/staging.rs
parent31fb8c89fefd3167b8b928cd75ddc008da60b434 (diff)
Remove `Artifact` type
This patch follows-up on the shrinking of the `Artifact` type and removes it entirely. The type is not needed. Only the `ArtifactPath` type is needed, which is a thin wrapper around `PathBuf`, ensuring that the path is relative to the store root. The `Artifact` type used `pom` to parse the name and version of the package from the `ArtifactPath` object it contained, which resulted in the restriction that the path must always be <name>-<version>... Which should not be a requirement and actually caused issues with a package named "foo-bar" (as an example). Signed-off-by: Matthias Beyer <matthias.beyer@atos.net> Tested-by: Matthias Beyer <matthias.beyer@atos.net>
Diffstat (limited to 'src/filestore/staging.rs')
-rw-r--r--src/filestore/staging.rs19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/filestore/staging.rs b/src/filestore/staging.rs
index 788cd02..1c2a848 100644
--- a/src/filestore/staging.rs
+++ b/src/filestore/staging.rs
@@ -10,16 +10,15 @@
use std::fmt::Debug;
-use anyhow::anyhow;
use anyhow::Context;
use anyhow::Error;
use anyhow::Result;
+use anyhow::anyhow;
use futures::stream::Stream;
use indicatif::ProgressBar;
use log::trace;
use result_inspect::ResultInspect;
-use crate::filestore::Artifact;
use crate::filestore::path::ArtifactPath;
use crate::filestore::path::StoreRoot;
use crate::filestore::util::FileStoreImpl;
@@ -84,14 +83,12 @@ impl StagingStore {
None
} else {
Some({
- 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())
- })
+ // Clippy doesn't detect this properly
+ #[allow(clippy::redundant_clone)]
+ ArtifactPath::new(path.to_path_buf())
+ .inspect(|r| trace!("Loaded from path {} = {:?}", path.display(), r))
+ .with_context(|| anyhow!("Loading from path: {}", path.display()))
+ .map(|ap| self.0.load_from_path(&ap).clone())
})
}
})
@@ -102,7 +99,7 @@ impl StagingStore {
self.0.root_path()
}
- pub fn get(&self, p: &ArtifactPath) -> Option<&Artifact> {
+ pub fn get(&self, p: &ArtifactPath) -> Option<&ArtifactPath> {
self.0.get(p)
}
}