refactor: rename soft-delete marker from .deleted to .closed

Internal rename: DELETE_MARKER -> CLOSE_MARKER, DeleteMarker ->
CloseMarker, is_deleted -> is_closed. The batch UUID is dropped;
undo now groups cases by their exact closed_at timestamp, which
bulk-close writes identically across its selection while per-case
close writes a unique stamp.

Behavior unchanged. No migration (project is pre-production);
legacy .deleted files in tmpdata were removed manually.
This commit is contained in:
2026-04-21 10:36:55 +02:00
parent a8389a89db
commit 9410d6daaa
13 changed files with 131 additions and 145 deletions
+9 -18
View File
@@ -3,9 +3,8 @@ use std::sync::Arc;
use axum::extract::State;
use axum::response::Redirect;
use axum_extra::extract::Form;
use doctate_common::timestamp::now_rfc3339;
use serde::Deserialize;
use time::OffsetDateTime;
use time::format_description::well_known::Rfc3339;
use tracing::{info, warn};
use crate::analyze::{ANALYSIS_INPUT_FILE, AnalyzeJob, AnalyzeSender, DOCUMENT_FILE};
@@ -13,7 +12,7 @@ use crate::auth::AuthenticatedWebUser;
use crate::config::Config;
use crate::error::AppError;
use crate::events::{self, CaseEventKind, EventSender};
use crate::paths::{DeleteMarker, write_delete_marker};
use crate::paths::{CloseMarker, write_close_marker};
use crate::routes::case_actions::{
build_analysis_input, reset_case_artefacts, write_input_create_new,
};
@@ -140,16 +139,9 @@ async fn bulk_delete(
user_root: &std::path::Path,
case_ids: &[String],
) {
// One batch UUID + one timestamp shared across the entire bulk action,
// so undo can restore exactly this group.
let batch = uuid::Uuid::new_v4();
let deleted_at = match OffsetDateTime::now_utc().format(&Rfc3339) {
Ok(s) => s,
Err(e) => {
warn!(slug = %slug, error = %e, "bulk-delete: failed to format timestamp");
return;
}
};
// Shared `closed_at` across the whole bulk action: identical timestamp
// groups the cases so a subsequent undo can restore exactly this click.
let closed_at = now_rfc3339();
let mut ok = 0usize;
let mut skipped = 0usize;
for case_id in case_ids {
@@ -163,11 +155,10 @@ async fn bulk_delete(
skipped += 1;
continue;
};
let marker = DeleteMarker {
batch,
deleted_at: deleted_at.clone(),
let marker = CloseMarker {
closed_at: closed_at.clone(),
};
if let Err(e) = write_delete_marker(&case_dir, &marker).await {
if let Err(e) = write_close_marker(&case_dir, &marker).await {
warn!(slug = %slug, case_id = %case_id, error = %e, "bulk-delete: write marker failed");
skipped += 1;
continue;
@@ -175,7 +166,7 @@ async fn bulk_delete(
events::emit(events_tx, slug, case_id, CaseEventKind::CaseDeleted);
ok += 1;
}
info!(slug = %slug, batch = %batch, ok, skipped, "bulk-delete completed");
info!(slug = %slug, closed_at = %closed_at, ok, skipped, "bulk-delete completed");
}
async fn bulk_reset(