2
0
Fork 0
mirror of https://git.asonix.dog/asonix/pict-rs synced 2024-12-22 11:21:24 +00:00

Switch many migration logs to debug, flush changes to new db

This commit is contained in:
asonix 2020-10-16 16:02:48 -05:00
parent e869505c67
commit b64e3615be
3 changed files with 10 additions and 5 deletions

2
Cargo.lock generated
View file

@ -1446,7 +1446,7 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
[[package]]
name = "pict-rs"
version = "0.2.3"
version = "0.2.4"
dependencies = [
"actix-form-data",
"actix-fs",

View file

@ -1,7 +1,7 @@
[package]
name = "pict-rs"
description = "A simple image hosting service"
version = "0.2.3"
version = "0.2.4"
authors = ["asonix <asonix@asonix.dog>"]
license = "AGPL-3.0"
readme = "README.md"

View file

@ -172,7 +172,7 @@ where
if !k.contains(&b"/"[0]) {
if let Some(id) = old_alias_tree.get(alias_id_key(&String::from_utf8_lossy(&k)))? {
counter += 1;
info!("Migrating alias #{}", counter);
debug!("Migrating alias #{}", counter);
// k is an alias
migrate_main_tree(&k, &v, &old_db, &new_db, &String::from_utf8_lossy(&id))?;
debug!(
@ -190,6 +190,7 @@ where
}
new_alias_tree.insert(k.clone(), v)?;
new_migrate_tree.insert("last_migrated", k)?;
new_alias_tree.flush()?;
new_migrate_tree.flush()?;
} else {
warn!("MISSING {}", String::from_utf8_lossy(k.as_ref()));
@ -198,6 +199,7 @@ where
info!("Moved {} unique aliases", counter);
new_migrate_tree.insert("done", "true")?;
new_migrate_tree.flush()?;
Ok(new_db)
}
@ -224,7 +226,8 @@ where
if let Some(filename) = old_db.self_tree().get(&hash)? {
main_tree.insert(&hash, filename.clone())?;
new_fname_tree.insert(filename, hash.clone())?;
main_tree.flush()?;
new_fname_tree.flush()?;
} else {
warn!("Missing filename");
}
@ -232,6 +235,7 @@ where
let key = alias_key(&hash, id);
if let Some(v) = old_db.self_tree().get(&key)? {
main_tree.insert(key, v)?;
main_tree.flush()?;
} else {
warn!("Not migrating alias {} id {}", String::from_utf8_lossy(&alias), id);
return Ok(());
@ -245,8 +249,9 @@ where
let (k, v) = res?;
debug!("Moving variant #{} for {}", counter, String::from_utf8_lossy(v.as_ref()));
main_tree.insert(k, v)?;
main_tree.flush()?;
}
info!("Moved {} variants for {}", counter, String::from_utf8_lossy(alias.as_ref()));
debug!("Moved {} variants for {}", counter, String::from_utf8_lossy(alias.as_ref()));
}
Ok(())