From af5e9721e1ff4520f9e4e39113cc782598206428 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 6 Apr 2021 20:36:17 +0200 Subject: Remove pub from FileStoreImpl::root_path member And replace it with a getset::Getters implementation. Signed-off-by: Matthias Beyer --- src/filestore/path.rs | 2 +- src/filestore/release.rs | 2 +- src/filestore/staging.rs | 6 +++--- src/filestore/util.rs | 14 ++++++-------- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/filestore/path.rs b/src/filestore/path.rs index 4d75855..e8c7a26 100644 --- a/src/filestore/path.rs +++ b/src/filestore/path.rs @@ -143,7 +143,7 @@ pub struct FullArtifactPath<'a>(&'a StoreRoot, &'a ArtifactPath); impl<'a> FullArtifactPath<'a> { pub fn is_in_staging_store(&self, store: &StagingStore) -> bool { - store.0.root == *self.0 + store.0.root_path() == self.0 } pub fn artifact_path(&self) -> &ArtifactPath { diff --git a/src/filestore/release.rs b/src/filestore/release.rs index a990821..188de04 100644 --- a/src/filestore/release.rs +++ b/src/filestore/release.rs @@ -22,7 +22,7 @@ pub struct ReleaseStore(pub(in crate::filestore) FileStoreImpl); impl Debug for ReleaseStore { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::result::Result<(), std::fmt::Error> { - write!(f, "ReleaseStore(root: {})", self.0.root.display()) + write!(f, "ReleaseStore(root: {})", self.0.root_path().display()) } } diff --git a/src/filestore/staging.rs b/src/filestore/staging.rs index 321ba6d..73701cd 100644 --- a/src/filestore/staging.rs +++ b/src/filestore/staging.rs @@ -27,7 +27,7 @@ pub struct StagingStore(pub(in crate::filestore) FileStoreImpl); impl Debug for StagingStore { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::result::Result<(), std::fmt::Error> { - write!(f, "StagingStore(root: {})", self.0.root.display()) + write!(f, "StagingStore(root: {})", self.0.root_path().display()) } } @@ -47,7 +47,7 @@ impl StagingStore { { use futures::stream::TryStreamExt; - let dest = &self.0.root; + let dest = self.0.root_path(); stream .try_concat() .await @@ -78,7 +78,7 @@ impl StagingStore { .into_iter() .inspect(|p| trace!("Trying to load into staging store: {}", p.display())) .filter_map(|path| { - if self.0.root.is_dir(&path) { + if self.0.root_path().is_dir(&path) { None } else { Some({ diff --git a/src/filestore/util.rs b/src/filestore/util.rs index ec6ecfd..ebfbbd7 100644 --- a/src/filestore/util.rs +++ b/src/filestore/util.rs @@ -25,15 +25,17 @@ use crate::filestore::path::StoreRoot; /// provide this type as the implementation. /// /// It can then be wrapped into the actual interface of this module with specialized functionality. +#[derive(getset::Getters)] pub struct FileStoreImpl { - pub(in crate::filestore) root: StoreRoot, + #[getset(get = "pub")] + root_path: StoreRoot, store: HashSet, } impl FileStoreImpl { /// Loads the passed path recursively - pub fn load(root: StoreRoot, progress: &ProgressBar) -> Result { - let store = root + pub fn load(root_path: StoreRoot, progress: &ProgressBar) -> Result { + let store = root_path .find_artifacts_recursive() .inspect(|path| { log::trace!("Found artifact path: {:?}", path); @@ -41,11 +43,7 @@ impl FileStoreImpl { }) .collect::>>()?; - Ok(FileStoreImpl { root, store }) - } - - pub fn root_path(&self) -> &StoreRoot { - &self.root + Ok(FileStoreImpl { root_path, store }) } pub fn get(&self, artifact_path: &ArtifactPath) -> Option<&ArtifactPath> { -- cgit v1.2.3