summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2021-04-06 20:36:17 +0200
committerMatthias Beyer <mail@beyermatthias.de>2021-04-06 20:36:18 +0200
commitaf5e9721e1ff4520f9e4e39113cc782598206428 (patch)
treed589826c9f29ec20fa21597e7ce165eb17382de0
parent5ac28f0dae851a3401b835813548f301ed118af5 (diff)
Remove pub from FileStoreImpl::root_path member
And replace it with a getset::Getters implementation. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--src/filestore/path.rs2
-rw-r--r--src/filestore/release.rs2
-rw-r--r--src/filestore/staging.rs6
-rw-r--r--src/filestore/util.rs14
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<ArtifactPath>,
}
impl FileStoreImpl {
/// Loads the passed path recursively
- pub fn load(root: StoreRoot, progress: &ProgressBar) -> Result<Self> {
- let store = root
+ pub fn load(root_path: StoreRoot, progress: &ProgressBar) -> Result<Self> {
+ let store = root_path
.find_artifacts_recursive()
.inspect(|path| {
log::trace!("Found artifact path: {:?}", path);
@@ -41,11 +43,7 @@ impl FileStoreImpl {
})
.collect::<Result<HashSet<ArtifactPath>>>()?;
- 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> {