From 1f3298363f5a6e640c8aaf13496464d19c637194 Mon Sep 17 00:00:00 2001 From: asonix Date: Sat, 22 Jul 2023 19:55:50 -0500 Subject: [PATCH] Attempt to mark unmarked variants as accessed on launch --- src/lib.rs | 6 ++++++ src/repo/sled.rs | 21 ++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index c1fe024..c326561 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1692,6 +1692,9 @@ impl PictRsConfiguration { sled_repo .requeue_in_progress(config.server.worker_id.as_bytes().to_vec()) .await?; + sled_repo + .mark_accessed::<::Identifier>() + .await?; launch_file_store(sled_repo, store, client, config, sled_extra_config) .await?; @@ -1734,6 +1737,9 @@ impl PictRsConfiguration { sled_repo .requeue_in_progress(config.server.worker_id.as_bytes().to_vec()) .await?; + sled_repo + .mark_accessed::<::Identifier>() + .await?; launch_object_store(sled_repo, store, client, config, sled_extra_config) .await?; diff --git a/src/repo/sled.rs b/src/repo/sled.rs index 6b0e8e9..e4fe02e 100644 --- a/src/repo/sled.rs +++ b/src/repo/sled.rs @@ -133,7 +133,26 @@ impl SledRepo { Ok(db) } - #[tracing::instrument(level = "warn")] + #[tracing::instrument(level = "debug", skip_all)] + pub(crate) async fn mark_accessed(&self) -> Result<(), StoreError> { + use futures_util::StreamExt; + + let mut stream = self.hashes().await; + + while let Some(res) = stream.next().await { + let hash = res?; + + for (variant, _) in self.variants::(hash.clone()).await? { + if !self.contains_variant(hash.clone(), variant.clone()).await? { + VariantAccessRepo::accessed(self, hash.clone(), variant).await?; + } + } + } + + Ok(()) + } + + #[tracing::instrument(level = "warn", skip_all)] pub(crate) async fn export(&self) -> Result<(), RepoError> { let path = self .export_path