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:
@@ -128,7 +128,8 @@ async fn empty_user_dir_returns_200_empty_list() {
|
||||
assert_eq!(response.status(), StatusCode::OK);
|
||||
|
||||
let etag = header_str(&response, "etag");
|
||||
assert!(etag.starts_with("W/\"0-16\""), "etag was {etag:?}");
|
||||
assert!(etag.starts_with("W/\""), "etag was {etag:?}");
|
||||
assert!(etag.ends_with("-16\""), "etag was {etag:?}");
|
||||
|
||||
let body = body_json(response).await;
|
||||
assert_eq!(body["window_hours"], 16);
|
||||
|
||||
Reference in New Issue
Block a user