Attempt to mark unmarked variants as accessed on launch

This commit is contained in:
asonix 2023-07-22 19:55:50 -05:00
parent fe1f7c869f
commit 1f3298363f
2 changed files with 26 additions and 1 deletions

View File

@ -1692,6 +1692,9 @@ impl PictRsConfiguration {
sled_repo
.requeue_in_progress(config.server.worker_id.as_bytes().to_vec())
.await?;
sled_repo
.mark_accessed::<<FileStore as Store>::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::<<ObjectStore as Store>::Identifier>()
.await?;
launch_object_store(sled_repo, store, client, config, sled_extra_config)
.await?;

View File

@ -133,7 +133,26 @@ impl SledRepo {
Ok(db)
}
#[tracing::instrument(level = "warn")]
#[tracing::instrument(level = "debug", skip_all)]
pub(crate) async fn mark_accessed<I: Identifier + 'static>(&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::<I>(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