summaryrefslogtreecommitdiffstats
path: root/src/filestore
diff options
context:
space:
mode:
Diffstat (limited to 'src/filestore')
-rw-r--r--src/filestore/merged.rs98
-rw-r--r--src/filestore/mod.rs3
-rw-r--r--src/filestore/path.rs4
3 files changed, 0 insertions, 105 deletions
diff --git a/src/filestore/merged.rs b/src/filestore/merged.rs
deleted file mode 100644
index 1503870..0000000
--- a/src/filestore/merged.rs
+++ /dev/null
@@ -1,98 +0,0 @@
-//
-// Copyright (c) 2020-2021 science+computing ag and other contributors
-//
-// This program and the accompanying materials are made
-// available under the terms of the Eclipse Public License 2.0
-// which is available at https://www.eclipse.org/legal/epl-2.0/
-//
-// SPDX-License-Identifier: EPL-2.0
-//
-
-// TODO: The MergedStores is not used at all anymore, because we removed the feature while doing
-// the rewrite
-#![allow(unused)]
-
-use std::sync::Arc;
-use std::path::Path;
-
-use anyhow::anyhow;
-use anyhow::Result;
-use getset::Getters;
-use log::trace;
-use tokio::sync::RwLock;
-
-use crate::filestore::path::ArtifactPath;
-use crate::filestore::path::FullArtifactPath;
-use crate::filestore::ReleaseStore;
-use crate::filestore::StagingStore;
-
-
-/// A type that merges the release store and the staging store
-///
-/// The stores are not actually merged (on disk or in memory), but the querying mechanism works in
-/// a way where it _always_ preferes the staging store over the release store.
-///
-#[derive(Clone, Getters)]
-pub struct MergedStores {
- #[getset(get = "pub")]
- release: Arc<RwLock<ReleaseStore>>,
-
- #[getset(get = "pub")]
- staging: Arc<RwLock<StagingStore>>,
-}
-
-impl MergedStores {
- pub fn new(release: Arc<RwLock<ReleaseStore>>, staging: Arc<RwLock<StagingStore>>) -> Self {
- MergedStores { release, staging }
- }
-
- pub async fn get_artifact_by_path(&self, p: &Path) -> Result<Option<ArtifactPath>> {
- trace!("Fetching artifact from path: {:?}", p.display());
- let artifact_path = ArtifactPath::new(p.to_path_buf())?;
-
- let staging = &mut self.staging.write().await.0;
- let staging_path = staging
- .root_path()
- .join(&artifact_path)?
- .ok_or_else(|| anyhow!("Does not exist in staging store: {:?}", artifact_path))?;
- trace!("staging_path = {:?}", staging_path.display());
-
- if staging_path.exists() {
- let art = if let Some(art) = staging.get(&artifact_path) {
- art
- } else {
- trace!("Loading path from staging store: {:?}", artifact_path.display());
- staging.load_from_path(&artifact_path)
- };
-
- return Ok(Some(art.clone()))
- }
-
- let release = &mut self.release.write().await.0;
- let release_path = release.root_path()
- .join(&artifact_path)?
- .ok_or_else(|| anyhow!("Not found in release store: {:?}", artifact_path))?;
- trace!("release_path = {:?}", release_path);
-
- if release_path.exists() {
- let art = if let Some(art) = release.get(&artifact_path) {
- art
- } else {
- trace!("Loading path from release store: {:?}", artifact_path.display());
- release.load_from_path(&artifact_path)
- };
- return Ok(Some(art.clone()))
- }
-
- Ok(None)
- }
-
- pub async fn get(&self, p: &ArtifactPath) -> Option<ArtifactPath> {
- if let Some(a) = self.staging.read().await.get(p).cloned() {
- return Some(a)
- }
-
- self.release.read().await.get(p).cloned()
- }
-
-}
diff --git a/src/filestore/mod.rs b/src/filestore/mod.rs
index 29eb476..8d788e2 100644
--- a/src/filestore/mod.rs
+++ b/src/filestore/mod.rs
@@ -14,9 +14,6 @@ pub use release::*;
mod staging;
pub use staging::*;
-mod merged;
-pub use merged::*;
-
pub mod path;
pub use path::ArtifactPath;
diff --git a/src/filestore/path.rs b/src/filestore/path.rs
index 19016bd..4d75855 100644
--- a/src/filestore/path.rs
+++ b/src/filestore/path.rs
@@ -154,10 +154,6 @@ impl<'a> FullArtifactPath<'a> {
self.0 .0.join(&self.1 .0)
}
- pub fn exists(&self) -> bool {
- self.joined().exists()
- }
-
pub fn display(&self) -> FullArtifactPathDisplay<'a> {
FullArtifactPathDisplay(self.0, self.1)
}