Refactor ETag generation for oneliners API
Remove the per-user oneliner watermark, which was previously used to generate ETags for the `/api/oneliners` endpoint. The watermark was intended to track the last successful oneliner write for each user. The ETag generation has been refactored to use a deterministic FNV-1a hash. This hash is computed over a sorted list of tuples containing `(case_id, last_recording_at_ns, oneliner_mtime_ns)` for all visible cases. This approach ensures that the ETag changes whenever any listen-relevant file system modification occurs, such as a new recording, oneliner regeneration, soft-delete, undo, or upload-auto-reopen. This new method is more robust and avoids the complexity of managing per-user state. The `OnelinerWatermark` type alias and its associated logic have been removed from `AppState` and the relevant modules (`transcribe::worker`, `transcribe::recovery`, `routes::oneliners`, `main`). New integration tests have been added to verify that various delete operations (single delete, undo delete, bulk delete) correctly trigger an ETag update, ensuring cache invalidation.
This commit is contained in:
@@ -288,10 +288,7 @@ async fn worker_renames_audio_to_failed_on_whisper_error() {
|
||||
let client = reqwest::Client::new();
|
||||
let busy = std::sync::Arc::new(std::sync::atomic::AtomicBool::new(false));
|
||||
let vocab = std::sync::Arc::new(doctate_server::gazetteer::Gazetteer::empty());
|
||||
let watermark: doctate_server::OnelinerWatermark = std::sync::Arc::new(
|
||||
tokio::sync::RwLock::new(std::collections::HashMap::new()),
|
||||
);
|
||||
transcribe::worker::run(rx, config, client, busy, vocab, watermark).await;
|
||||
transcribe::worker::run(rx, config, client, busy, vocab).await;
|
||||
|
||||
// Audio must have been renamed so recovery skips it next time.
|
||||
assert!(!audio.exists(), "original .m4a still present");
|
||||
@@ -340,10 +337,7 @@ async fn transcribe_worker_normalizes_whisper_output() {
|
||||
|
||||
let client = reqwest::Client::new();
|
||||
let busy = std::sync::Arc::new(std::sync::atomic::AtomicBool::new(false));
|
||||
let watermark: doctate_server::OnelinerWatermark = std::sync::Arc::new(
|
||||
tokio::sync::RwLock::new(std::collections::HashMap::new()),
|
||||
);
|
||||
transcribe::worker::run(rx, config, client, busy, vocab, watermark).await;
|
||||
transcribe::worker::run(rx, config, client, busy, vocab).await;
|
||||
|
||||
let transcript_path = case_dir.join("2026-04-13T10-30-00Z.transcript.txt");
|
||||
assert!(transcript_path.exists(), "transcript missing");
|
||||
|
||||
Reference in New Issue
Block a user