2
0
Fork 0
mirror of https://git.asonix.dog/asonix/pict-rs synced 2024-12-22 19:31:35 +00:00

Add logging to migration

This commit is contained in:
asonix 2023-08-15 19:33:19 -05:00
parent 1ee77b19d8
commit 9fe7410dd6
2 changed files with 17 additions and 3 deletions

View file

@ -14,8 +14,9 @@ buffer_capacity = 102400
service_name = 'pict-rs'
targets = 'info'
[old_db]
path = 'data/'
[old_repo]
path = 'data/sled-repo-local'
cache_capacity = 67108864
[media]
max_file_size = 40

View file

@ -11,6 +11,7 @@ use crate::{
stream::IntoStreamer,
};
#[tracing::instrument(skip_all)]
pub(crate) async fn migrate_04<S: Store>(
old_repo: OldSledRepo,
new_repo: &ArcRepo,
@ -31,17 +32,27 @@ pub(crate) async fn migrate_04<S: Store>(
return Err(e.into());
}
let total_size = old_repo.size().await?;
let pct = (total_size / 100).max(1);
tracing::warn!("Checks complete, migrating repo");
tracing::warn!("{} hashes will be migrated", old_repo.size().await?);
tracing::warn!("{total_size} hashes will be migrated");
let mut hash_stream = old_repo.hashes().await.into_streamer();
let mut index = 0;
while let Some(res) = hash_stream.next().await {
index += 1;
if let Ok(hash) = res {
let _ = migrate_hash_04(&old_repo, new_repo, store, config, hash).await;
} else {
tracing::warn!("Failed to read hash, skipping");
}
if index % pct == 0 {
let percent = index / pct;
tracing::warn!("Migration {percent}% complete - {index}/{total_size}");
}
}
if let Some(generator_state) = old_repo.get("last-path").await? {
@ -84,6 +95,7 @@ async fn migrate_hash_04<S: Store>(
Ok(())
}
#[tracing::instrument(skip_all)]
async fn do_migrate_hash_04<S: Store>(
old_repo: &OldSledRepo,
new_repo: &ArcRepo,
@ -156,6 +168,7 @@ async fn do_migrate_hash_04<S: Store>(
Ok(())
}
#[tracing::instrument(skip_all)]
async fn details<S: Store>(
old_repo: &OldSledRepo,
store: &S,