1
0
Fork 0
mirror of https://gitlab.com/famedly/conduit.git synced 2025-07-12 16:58:35 +00:00

use the sha2 of the key and add database migrations

This commit is contained in:
Shady Khalifa 2023-04-24 22:53:19 +02:00
parent 37952c1a19
commit ca86b1772f
No known key found for this signature in database
GPG key ID: 52DFAC81BEA54EAA
3 changed files with 47 additions and 5 deletions

View file

@ -880,6 +880,27 @@ impl KeyValueDatabase {
warn!("Migration: 11 -> 12 finished");
}
if services().globals.database_version()? < 13 {
// Move old media files to new names
for (key, _) in db.mediaid_file.iter() {
// we know that this method is deprecated, but we need to use it to migrate the old files
// to the new location
//
// TODO: remove this once we're sure that all users have migrated
#[allow(deprecated)]
let old_path = services().globals.get_media_file_old(&key);
let path = services().globals.get_media_file(&key);
// move the file to the new location
if old_path.exists() {
tokio::fs::rename(&old_path, &path).await?;
}
}
services().globals.bump_database_version(13)?;
warn!("Migration: 12 -> 13 finished");
}
assert_eq!(
services().globals.database_version().unwrap(),
latest_database_version