mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-01 07:58:23 +00:00
update old record with token
This commit is contained in:
1 parent
922e76eeb1
commit
44d75baeec
5 files changed
+29
-4
No files matched your search
Generated
+1
@@ -3519,6 +3519,7 @@ dependencies = [
|
||||
"easyenv",
|
||||
"enums",
|
||||
"errors",
|
||||
"filesys",
|
||||
"hashing",
|
||||
"log",
|
||||
"my-workspace-hack",
|
||||
|
||||
@@ -20,6 +20,7 @@ config = { path = "../../lib/deprecated/config" }
|
||||
easyenv = { path = "../../lib/easyenv" }
|
||||
enums = { path = "../../_types/enums" }
|
||||
errors = { path = "../../lib/errors" }
|
||||
filesys = { path = "../../lib/files/filesys" }
|
||||
hashing = { path = "../../lib/files/hashing" }
|
||||
mysql_queries = { path = "../../lib/mysql_queries" }
|
||||
storyteller_root = { path = "../../lib/storyteller_root" }
|
||||
|
||||
+8
@@ -4,6 +4,8 @@ use buckets::public::weight_files::bucket_file_path::WeightFileBucketPath;
|
||||
use cloud_storage::bucket_path_unifier::BucketPathUnifier;
|
||||
use enums::by_table::voice_conversion_models::voice_conversion_model_type::VoiceConversionModelType;
|
||||
use errors::{anyhow, AnyhowResult};
|
||||
use filesys::safe_delete_temp_directory::safe_delete_temp_directory;
|
||||
use filesys::safe_delete_temp_file::safe_delete_temp_file;
|
||||
use hashing::sha256::sha256_hash_file::sha256_hash_file;
|
||||
use mysql_queries::queries::model_weights::migration::upsert_model_weight_from_voice_conversion_model::CopiedFileData;
|
||||
use mysql_queries::queries::voice_conversion::migration::list_whole_voice_conversion_models_using_cursor::WholeVoiceConversionModelRecord;
|
||||
@@ -48,6 +50,9 @@ async fn copy_model(model: &WholeVoiceConversionModelRecord, deps: &Deps) -> Any
|
||||
&model_temp_fs_path,
|
||||
"application/octet-stream").await?;
|
||||
|
||||
safe_delete_temp_file(&model_temp_fs_path);
|
||||
safe_delete_temp_directory(&temp_dir);
|
||||
|
||||
Ok(CopiedFileData {
|
||||
bucket_path: new_model_bucket_path,
|
||||
file_sha_hash: file_checksum,
|
||||
@@ -73,5 +78,8 @@ async fn copy_index_file(model: &WholeVoiceConversionModelRecord, deps: &Deps, b
|
||||
&model_temp_fs_path,
|
||||
"application/octet-stream").await?;
|
||||
|
||||
safe_delete_temp_file(&model_temp_fs_path);
|
||||
safe_delete_temp_directory(&temp_dir);
|
||||
|
||||
Ok(()) // NB: We don't care about the path of the index file.
|
||||
}
|
||||
@@ -61,7 +61,10 @@ async fn copy_model_record_and_bucket_files(record: &WholeVoiceConversionModelRe
|
||||
}
|
||||
}
|
||||
|
||||
upsert_model_weight_from_voice_conversion_model(record, &deps.mysql_production, maybe_copied_data.as_ref()).await?;
|
||||
if let Some(copied_data) = &maybe_copied_data {
|
||||
info!("Upserting records...");
|
||||
upsert_model_weight_from_voice_conversion_model(record, &deps.mysql_production, copied_data).await?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
+15
-3
@@ -22,14 +22,14 @@ pub struct CopiedFileData {
|
||||
pub async fn upsert_model_weight_from_voice_conversion_model(
|
||||
record: &WholeVoiceConversionModelRecord,
|
||||
mysql_pool: &MySqlPool,
|
||||
maybe_copied_data: Option<&CopiedFileData>,
|
||||
copied_data: &CopiedFileData,
|
||||
) -> AnyhowResult<()> {
|
||||
|
||||
let mut transaction = mysql_pool.begin().await?;
|
||||
|
||||
let model_weight_token = create_or_generate_token(record);
|
||||
|
||||
upsert_model_weights_record(record, &model_weight_token, maybe_copied_data, &mut transaction).await?;
|
||||
upsert_model_weights_record(record, &model_weight_token, copied_data, &mut transaction).await?;
|
||||
upsert_model_weights_extension_record(record, &model_weight_token, &mut transaction).await?;
|
||||
|
||||
update_original_record(record, &model_weight_token, &mut transaction).await?;
|
||||
@@ -49,7 +49,7 @@ pub fn create_or_generate_token(record: &WholeVoiceConversionModelRecord) -> Mod
|
||||
pub async fn upsert_model_weights_record(
|
||||
record: &WholeVoiceConversionModelRecord,
|
||||
model_weight_token: &ModelWeightToken,
|
||||
maybe_copied_data: Option<&CopiedFileData>,
|
||||
copied_data: &CopiedFileData,
|
||||
mut transaction: &mut Transaction<'_, MySql>,
|
||||
) -> AnyhowResult<()> {
|
||||
|
||||
@@ -226,6 +226,18 @@ pub async fn update_original_record(
|
||||
model_weight_token: &ModelWeightToken,
|
||||
transaction: &mut Transaction<'_, MySql>
|
||||
) -> AnyhowResult<()> {
|
||||
let query = sqlx::query!(
|
||||
r#"
|
||||
UPDATE voice_conversion_models
|
||||
SET
|
||||
maybe_migration_new_model_weights_token = ?
|
||||
WHERE token = ?
|
||||
"#,
|
||||
model_weight_token,
|
||||
record.token,
|
||||
);
|
||||
|
||||
let _r = query.execute(&mut **transaction).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in new issue
Block a user