summaryrefslogtreecommitdiffstats
path: root/src/filestore/staging.rs
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-12-07 13:31:33 +0100
committerMatthias Beyer <mail@beyermatthias.de>2020-12-07 13:31:33 +0100
commit17e907e1863d8fecf25edac01d81d595b45a9b69 (patch)
tree55deefea0f5905eb942e8e35f9994c450044e538 /src/filestore/staging.rs
parent83b3b97fee854e19c63999e4daadf802784a1499 (diff)
Add ArtifactPath, StoreRoot
This is the first step towards strong path typing for distinction between artifact pathes. It adds a type for Store root pathes and a type for artifact pathes. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/filestore/staging.rs')
-rw-r--r--src/filestore/staging.rs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/filestore/staging.rs b/src/filestore/staging.rs
index cbc8732..86e22ae 100644
--- a/src/filestore/staging.rs
+++ b/src/filestore/staging.rs
@@ -1,6 +1,5 @@
use std::fmt::Debug;
use std::path::Path;
-use std::path::PathBuf;
use anyhow::Context;
use anyhow::Error;
@@ -12,6 +11,8 @@ use log::trace;
use result_inspect::ResultInspect;
use tar;
+use crate::filestore::path::ArtifactPath;
+use crate::filestore::path::StoreRoot;
use crate::filestore::util::FileStoreImpl;
// The implementation of this type must be available in the merged filestore.
@@ -33,7 +34,7 @@ impl StagingStore {
/// # Returns
///
/// Returns a list of Artifacts that were written from the stream
- pub async fn write_files_from_tar_stream<S>(&mut self, stream: S) -> Result<Vec<PathBuf>>
+ pub async fn write_files_from_tar_stream<S>(&mut self, stream: S) -> Result<Vec<ArtifactPath>>
where S: Stream<Item = Result<Vec<u8>>>
{
use futures::stream::TryStreamExt;
@@ -64,13 +65,14 @@ impl StagingStore {
.context("Concatenating the output bytestream")?
.into_iter()
.inspect(|p| trace!("Trying to load into staging store: {}", p.display()))
+ .map(ArtifactPath::new)
.filter_map(|path| {
let fullpath = self.0.root.join(&path);
if fullpath.is_dir() {
None
} else {
Some({
- self.0.load_from_path(&fullpath)
+ self.0.load_from_path(fullpath.as_ref())
.inspect(|r| trace!("Loaded from path {} = {:?}", fullpath.display(), r))
.with_context(|| anyhow!("Loading from path: {}", fullpath.display()))
.map_err(Error::from)
@@ -81,7 +83,7 @@ impl StagingStore {
.collect()
}
- pub fn root_path(&self) -> &Path {
+ pub fn root_path(&self) -> &StoreRoot {
self.0.root_path()
}