Feature/unified nl search #106
+7
-38
@@ -1121,44 +1121,13 @@ async fn pregen_one(
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if MP4 already on disk (from a previous run that crashed after render)
|
// Past the key-aware dedup above, any MP4 already at this key was NOT
|
||||||
let mp4_path = reel_mp4_path(app_state, &key);
|
// pre-generated by us (it has no matching ledger row) — most likely an
|
||||||
if mp4_path.exists() {
|
// on-demand fast-scripted reel that happens to share the key. Don't adopt
|
||||||
log::info!(
|
// it: regenerate so the precomputed reel is the agentic one. produce_reel
|
||||||
"Precomputed reel MP4 already exists for key={}, recording ledger and skipping render",
|
// publishes atomically, overwriting whatever is there. (The narrow
|
||||||
key
|
// render-succeeded-but-ledger-write-failed crash window just costs one
|
||||||
);
|
// redundant re-render next run.)
|
||||||
// Read title from sidecar if available
|
|
||||||
let sidecar_path = mp4_path.with_extension("json");
|
|
||||||
let title = if sidecar_path.exists() {
|
|
||||||
let sidecar = tokio::fs::read_to_string(&sidecar_path).await.ok();
|
|
||||||
sidecar
|
|
||||||
.and_then(|s| serde_json::from_str::<ReelSidecar>(&s).ok())
|
|
||||||
.map(|s| s.title)
|
|
||||||
.unwrap_or_else(|| format!("{} reel", span))
|
|
||||||
} else {
|
|
||||||
format!("{} reel", span)
|
|
||||||
};
|
|
||||||
let mut reel_dao = app_state.precomputed_reel_dao.lock().expect("lock");
|
|
||||||
reel_dao.record_reel(
|
|
||||||
&ctx,
|
|
||||||
&crate::database::models::InsertablePrecomputedReel {
|
|
||||||
span: span.to_string(),
|
|
||||||
library_key: library.to_string(),
|
|
||||||
cache_key: key.clone(),
|
|
||||||
output_path: mp4_path.to_string_lossy().to_string(),
|
|
||||||
title,
|
|
||||||
media_count,
|
|
||||||
render_version: RENDER_VERSION as i32,
|
|
||||||
tz_offset_minutes: tz,
|
|
||||||
voice: voice.clone(),
|
|
||||||
generated_at: now,
|
|
||||||
},
|
|
||||||
)?;
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate the reel
|
|
||||||
log::info!("Generating precomputed reel for span={}, key={}", span, key);
|
log::info!("Generating precomputed reel for span={}, key={}", span, key);
|
||||||
let (title, mp4) = produce_reel(
|
let (title, mp4) = produce_reel(
|
||||||
app_state,
|
app_state,
|
||||||
|
|||||||
Reference in New Issue
Block a user