From 366bba97cbb3b5b3a47093b0db964ed0bd0d7d4e Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Sun, 23 May 2021 13:43:50 -0400 Subject: [PATCH] store object name --- migrations/2021-05-15-071601_assets/up.sql | 6 ++++++ src/job/job_queries.rs | 7 +++++-- src/tts_download_job.rs | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/migrations/2021-05-15-071601_assets/up.sql b/migrations/2021-05-15-071601_assets/up.sql index 34596b98a8..c680f0cd16 100644 --- a/migrations/2021-05-15-071601_assets/up.sql +++ b/migrations/2021-05-15-071601_assets/up.sql @@ -79,6 +79,8 @@ CREATE TABLE tts_models ( -- For now, this will be a hash of the file contents. -- NB: NOT UNIQUE! We can allow duplicate uploads. private_bucket_hash CHAR(64) NOT NULL, + -- The "full url" version of the path + private_bucket_object_name VARCHAR(255) NOT NULL, -- Calculated average, on a scale of 0-100 -- Null with zero ratings. @@ -188,9 +190,13 @@ CREATE TABLE w2l_templates ( -- The original source image/video and the "precomputed" faces private_bucket_hash CHAR(64) NOT NULL, + -- The "full url" version of the path + private_bucket_object_name VARCHAR(255) NOT NULL, -- For the thumbnail we show. public_bucket_hash CHAR(64) NOT NULL, + -- The "full url" version of the path + public_bucket_object_name VARCHAR(255) NOT NULL, -- Calculated average, on a scale of 0-100 -- Null with zero ratings. diff --git a/src/job/job_queries.rs b/src/job/job_queries.rs index 91cb43449c..78e6fa2203 100644 --- a/src/job/job_queries.rs +++ b/src/job/job_queries.rs @@ -111,7 +111,8 @@ WHERE id = ? pub async fn insert_tts_model(pool: &MySqlPool, job: &TtsUploadJobRecord, - private_bucket_hash: &str) + private_bucket_hash: &str, + private_bucket_object_name: &str) -> AnyhowResult { let model_token = random_token(32); @@ -130,7 +131,8 @@ SET creator_user_token = ?, creator_ip_address = ?, original_download_url = ?, - private_bucket_hash = ? + private_bucket_hash = ?, + private_bucket_object_name = ? "#, model_token, updatable_slug, @@ -139,6 +141,7 @@ SET job.creator_ip_address.clone(), job.download_url.clone(), private_bucket_hash.to_string(), + private_bucket_object_name.to_string() ) .execute(pool) .await; diff --git a/src/tts_download_job.rs b/src/tts_download_job.rs index 5cbd7659c8..61d7522662 100644 --- a/src/tts_download_job.rs +++ b/src/tts_download_job.rs @@ -269,7 +269,7 @@ async fn process_job(downloader: &Downloader, job: &TtsUploadJobRecord) -> Anyho downloader.bucket_client.upload_filename(&object_name, &file_path).await?; info!("Saving model record..."); - let id = insert_tts_model(&downloader.mysql_pool, job, &private_bucket_hash).await?; + let id = insert_tts_model(&downloader.mysql_pool, job, &private_bucket_hash, &object_name).await?; info!("Saved model record: {}", id);