From cb6feaaa46cb36645ace0902f4b329b2ad790b80 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Sun, 21 Jan 2024 03:21:00 -0500 Subject: [PATCH] disable tts edit/delete when migrated --- .../src/text_to_speech/get_tts_model_info_migration.rs | 1 - .../src/http_server/endpoints/tts/delete_tts_model.rs | 6 ++++++ .../src/http_server/endpoints/tts/edit_tts_model.rs | 8 +++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/crates/lib/migration/src/text_to_speech/get_tts_model_info_migration.rs b/crates/lib/migration/src/text_to_speech/get_tts_model_info_migration.rs index a24c2ba77b..6b8ed7a5aa 100644 --- a/crates/lib/migration/src/text_to_speech/get_tts_model_info_migration.rs +++ b/crates/lib/migration/src/text_to_speech/get_tts_model_info_migration.rs @@ -222,7 +222,6 @@ impl TtsModelInfoMigration { } } - pub fn text_preprocessing_algorithm(&self) -> &str { match self { Self::LegacyTts(ref model) => &model.text_preprocessing_algorithm, diff --git a/crates/service/web/storyteller_web/src/http_server/endpoints/tts/delete_tts_model.rs b/crates/service/web/storyteller_web/src/http_server/endpoints/tts/delete_tts_model.rs index 4397bc0b0e..0aeef4fd62 100644 --- a/crates/service/web/storyteller_web/src/http_server/endpoints/tts/delete_tts_model.rs +++ b/crates/service/web/storyteller_web/src/http_server/endpoints/tts/delete_tts_model.rs @@ -76,6 +76,12 @@ pub async fn delete_tts_model_handler( request: web::Json, server_state: web::Data> ) -> Result { + // NB: Disable if we've migrated to model_weights + if server_state.flags.switch_tts_to_model_weights { + warn!("Migration to model_weights for tts. Cannot delete old model."); + return Err(DeleteTtsModelError::ServerError); + } + let maybe_user_session = server_state .session_checker .maybe_get_user_session(&http_request, &server_state.mysql_pool) diff --git a/crates/service/web/storyteller_web/src/http_server/endpoints/tts/edit_tts_model.rs b/crates/service/web/storyteller_web/src/http_server/endpoints/tts/edit_tts_model.rs index 5a690d90c9..71d3ac5c57 100644 --- a/crates/service/web/storyteller_web/src/http_server/endpoints/tts/edit_tts_model.rs +++ b/crates/service/web/storyteller_web/src/http_server/endpoints/tts/edit_tts_model.rs @@ -132,9 +132,15 @@ impl fmt::Display for EditTtsModelError { pub async fn edit_tts_model_handler( http_request: HttpRequest, path: Path, - request: web::Json, + request: Json, server_state: web::Data>) -> Result { + // NB: Disable if we've migrated to model_weights + if server_state.flags.switch_tts_to_model_weights { + warn!("Migration to model_weights for tts. Cannot delete old model."); + return Err(EditTtsModelError::ServerError); + } + let maybe_user_session = server_state .session_checker .maybe_get_user_session(&http_request, &server_state.mysql_pool)