Refactor: Simplify case directory structure

The distinction between `open/` and `done/` directories for cases has
been removed.
All cases for a user now reside directly under the user's directory
(e.g., `<data_path>/<slug>/<case_id>/`).

This simplifies path management and eliminates redundant directory
traversals.

Key changes include:
- Removed `open/` and `done/` subdirectories in path resolution.
- Introduced a `paths::case_dir` function as a single source of truth
  for case directory layout.
- Updated various modules (`recovery`, `auth`, `routes`, `transcribe`,
  `tests`) to use the new path structure.
- Adjusted templates to reflect the simplified case status
  representation.
This commit is contained in:
2026-04-15 22:15:13 +02:00
parent 70eed20909
commit 11eb645f3f
17 changed files with 190 additions and 324 deletions
+5 -10
View File
@@ -212,23 +212,18 @@ async fn recovery_enqueues_only_pending_recordings() {
let tmp = tempfile::tempdir().unwrap();
let root = tmp.path();
// User 1, open case with two .m4a — one pending, one already transcribed.
let case_a = root.join("dr_a/open/aaaa");
// User 1, case with two .m4a — one pending, one already transcribed.
let case_a = root.join("dr_a/aaaa");
std::fs::create_dir_all(&case_a).unwrap();
std::fs::write(case_a.join("2026-04-10T10-00-00Z.m4a"), b"x").unwrap();
std::fs::write(case_a.join("2026-04-11T10-00-00Z.m4a"), b"x").unwrap();
std::fs::write(case_a.join("2026-04-11T10-00-00Z.transcript.txt"), b"done").unwrap();
// User 2, open case with one pending .m4a.
let case_b = root.join("dr_b/open/bbbb");
// User 2, case with one pending .m4a.
let case_b = root.join("dr_b/bbbb");
std::fs::create_dir_all(&case_b).unwrap();
std::fs::write(case_b.join("2026-04-12T10-00-00Z.m4a"), b"x").unwrap();
// done/ cases must be ignored (not re-transcribed).
let case_c = root.join("dr_a/done/cccc");
std::fs::create_dir_all(&case_c).unwrap();
std::fs::write(case_c.join("2026-04-09T10-00-00Z.m4a"), b"x").unwrap();
let (tx, mut rx) = transcribe::channel();
scan_and_enqueue(root, &tx).await;
drop(tx); // close channel so the loop below terminates
@@ -275,7 +270,7 @@ async fn worker_renames_audio_to_failed_on_whisper_error() {
// Real case dir with a real m4a fixture so ffmpeg remux succeeds.
let tmp = tempfile::tempdir().unwrap();
let case_dir = tmp.path().join("dr_test/open/aaaa");
let case_dir = tmp.path().join("dr_test/aaaa");
std::fs::create_dir_all(&case_dir).unwrap();
let audio = case_dir.join("2026-04-13T10-30-00Z.m4a");
std::fs::copy(fixture("sample.m4a"), &audio).unwrap();