2
0
Fork 0
mirror of https://git.asonix.dog/asonix/pict-rs synced 2024-11-10 06:25:00 +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]] [[package]]
name = "pict-rs" name = "pict-rs"
version = "0.2.3" version = "0.2.4"
dependencies = [ dependencies = [
"actix-form-data", "actix-form-data",
"actix-fs", "actix-fs",

View file

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

View file

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