Compare commits

...
Author SHA1 Message Date
Brandon Thomas c5d63fa31f misc fixes for storyteller-web 2026-07-12 03:20:40 -04:00
12 changed files with 16 additions and 46 deletions
@@ -174,9 +174,9 @@ fn db_record_to_response_payload(
let progress_percentage = estimate_job_progress(&record, maybe_polymorphic_args.as_ref());
/// If the job is currently running, this is how long it has been running in seconds.
/// This is heuristic estimate since we don't record the precise start time across runs.
/// If the job's updated_at timestamp is updated elsewhere, then this is not accurate at all.
// If the job is currently running, this is how long it has been running in seconds.
// This is heuristic estimate since we don't record the precise start time across runs.
// If the job's updated_at timestamp is updated elsewhere, then this is not accurate at all.
let maybe_current_execution_duration_seconds = match record.status {
JobStatusPlus::Started => {
let now = Utc::now();
@@ -215,15 +215,11 @@ pub async fn batch_get_media_files_handler(
.await?;
let mut show_deleted_results = false;
let mut is_moderator = false;
if let Some(user_session) = maybe_user_session {
// NB: Moderators can see deleted results.
// Original creators cannot see them (unless they're moderators!)
show_deleted_results = user_session.can_delete_other_users_tts_results;
// Moderators get to see all the fields.
is_moderator = user_session.can_delete_other_users_tts_results
|| user_session.can_edit_other_users_tts_models;
}
let tokens = query.tokens.iter()
@@ -220,15 +220,11 @@ pub async fn get_media_file_handler(
.await?;
let mut show_deleted_results = false;
let mut is_moderator = false;
if let Some(user_session) = maybe_user_session {
// NB: Moderators can see deleted results.
// Original creators cannot see them (unless they're moderators!)
show_deleted_results = user_session.can_delete_other_users_tts_results;
// Moderators get to see all the fields.
is_moderator = user_session.can_delete_other_users_tts_results
|| user_session.can_edit_other_users_tts_models;
}
let media_domain = get_media_domain(&http_request);
@@ -51,15 +51,11 @@ pub async fn list_batch_generated_redux_media_files_handler(
.await?;
let mut show_deleted_results = false;
let mut is_moderator = false;
if let Some(user_session) = maybe_user_session {
// NB: Moderators can see deleted results.
// Original creators cannot see them (unless they're moderators!)
show_deleted_results = user_session.can_delete_other_users_tts_results;
// Moderators get to see all the fields.
is_moderator = user_session.can_delete_other_users_tts_results
|| user_session.can_edit_other_users_tts_models;
}
// NB(bt,2024-03-24): I'm sorry, this is gross. We're not respecting sorting, input ordering,
@@ -259,7 +259,6 @@ pub async fn upload_audio_media_file_handler(
};
let mut maybe_duration_millis = None;
let mut maybe_codec_name = None;
if do_audio_decode {
let basic_info = decode_basic_audio_bytes_info(
@@ -272,7 +271,6 @@ pub async fn upload_audio_media_file_handler(
})?;
maybe_duration_millis = basic_info.duration_millis;
maybe_codec_name = basic_info.codec_name;
}
// ==================== OTHER FILE METADATA ==================== //
@@ -170,7 +170,6 @@ pub async fn process_upload_media_file(
let file_size_bytes = bytes.len();
let mut maybe_duration_millis = None;
let mut maybe_codec_name = None;
let mut media_file_type = None;
let mut is_spz = false;
@@ -258,7 +257,6 @@ pub async fn process_upload_media_file(
})?;
maybe_duration_millis = basic_info.duration_millis;
maybe_codec_name = basic_info.codec_name;
}
}
@@ -367,6 +365,7 @@ pub async fn process_upload_media_file(
.creator_set_visibility(creator_set_visibility)
.mime_type(mime_type)
.file_size_bytes(file_size_bytes as u64)
.maybe_duration_millis(maybe_duration_millis)
.checksum_sha2(&hash)
.maybe_title(upload_media_request.title.as_deref())
.maybe_origin_filename(upload_media_request.file_name.as_deref())
@@ -244,20 +244,16 @@ fn keep_only_largest_pmx_file(mut entries: Vec<PmxZipEntryDetail>) -> Result<Vec
// Some zip files have entries with useless leading directories. This will remove them.
fn remove_useless_leading_directories(mut entries: Vec<PmxZipEntryDetail>) -> Result<Vec<PmxZipEntryDetail>, PmxError> {
let mut maybe_parent_directory_to_remove = None;
{
let maybe_parent_directory_to_remove = {
let pmx_entries = entries.iter()
.filter(|entry| entry.is_pmx)
.collect::<Vec<&PmxZipEntryDetail>>();
match pmx_entries.get(0) {
None => return Err(PmxError::NoPmxFile),
Some(pmx_file) => {
maybe_parent_directory_to_remove = pmx_file.enclosed_name.parent().map(|p| p.to_path_buf());
}
Some(pmx_file) => pmx_file.enclosed_name.parent().map(|p| p.to_path_buf()),
}
}
};
if let Some(parent) = maybe_parent_directory_to_remove {
info!("Common parent: {:?}", parent);
@@ -291,8 +291,8 @@ pub async fn upload_new_video_media_file_handler(
// Tempdirs we need to keep alive across the upload step. They get dropped at
// function exit which cleans up the on-disk files.
let mut transcode_tempdir_ref = None;
let mut resample_tempdir_ref = None;
let mut _transcode_tempdir_ref = None;
let mut _resample_tempdir_ref = None;
let mut final_upload_file_path = form.file.file.path().to_path_buf();
@@ -324,7 +324,7 @@ pub async fn upload_new_video_media_file_handler(
})?;
mimetype = "video/mp4".to_string();
final_upload_file_path = transcoded_path;
transcode_tempdir_ref = Some(transcode_tempdir);
_transcode_tempdir_ref = Some(transcode_tempdir);
}
// ==================== OPTIONAL VIDEO RESAMPLE ==================== //
@@ -374,7 +374,7 @@ pub async fn upload_new_video_media_file_handler(
})?;
final_upload_file_path = video_output_path;
resample_tempdir_ref = Some(frame_temp_dir); // NB: Keep from going out of scope
_resample_tempdir_ref = Some(frame_temp_dir); // NB: Keep from going out of scope
}
// True if we touched the user's file in any way (transcoded, resampled, or both).
@@ -4,7 +4,7 @@ use crate::state::server_state::ServerState;
pub const ALPHA_COOKIE_NAME : &str = "enable-alpha";
pub fn alpha_cookie(server_state: &ServerState) -> Cookie {
pub fn alpha_cookie(server_state: &ServerState) -> Cookie<'_> {
Cookie::build(ALPHA_COOKIE_NAME, "true")
.domain(&server_state.env_config.cookie_domain)
.secure(server_state.env_config.cookie_secure) // HTTPS-only
@@ -254,8 +254,8 @@ pub async fn omni_upload_video_media_file_handler(
// distribution format we want for the media file record. Transcode them to
// mp4 in a tempdir so we can resample / upload mp4 instead.
let mut transcode_tempdir_ref = None;
let mut resample_tempdir_ref = None;
let mut _transcode_tempdir_ref = None;
let mut _resample_tempdir_ref = None;
let mut final_upload_file_path = form.file.file.path().to_path_buf();
@@ -284,7 +284,7 @@ pub async fn omni_upload_video_media_file_handler(
})?;
mimetype = "video/mp4".to_string();
final_upload_file_path = transcoded_path;
transcode_tempdir_ref = Some(transcode_tempdir);
_transcode_tempdir_ref = Some(transcode_tempdir);
}
// ==================== OPTIONAL VIDEO RESAMPLE ==================== //
@@ -331,7 +331,7 @@ pub async fn omni_upload_video_media_file_handler(
})?;
final_upload_file_path = video_output_path;
resample_tempdir_ref = Some(frame_temp_dir); // NB: Keep from going out of scope
_resample_tempdir_ref = Some(frame_temp_dir); // NB: Keep from going out of scope
}
// True if we touched the user's file in any way (transcoded, resampled, or both).
@@ -48,15 +48,6 @@ pub struct UserSessionSubscriptionPlan {
pub subscription_expires_at: DateTime<Utc>,
}
impl Default for UserSessionSubscriptionPlan {
fn default() -> Self {
Self {
subscription_expires_at: chrono::MIN_DATETIME,
..Default::default()
}
}
}
#[derive(Clone, Default)]
pub struct UserSessionPreferences {
pub disable_gravatar: bool,
@@ -48,6 +48,4 @@ pub async fn db_health_checker_thread(
tokio::time::sleep(check_duration).await;
}
warn!("Should never happen: Health Checker Exits");
}