Add delete marker support to paths
Introduce DeleteMarker struct and associated functions for managing soft-delete markers within case directories. This enables tracking deleted cases and supports undo functionality. feat: Add delete marker support to paths Introduces a `.deleted` file to mark cases as soft-deleted. The marker contains a `batch` UUID for grouping deletions and a `deleted_at` timestamp for ordering. New functions `is_deleted`, `read_delete_marker`, and `write_delete_marker` are added to manage this marker. The `locate_case` function is updated to also consider soft-deleted cases as not found.
This commit is contained in:
@@ -166,14 +166,17 @@ pub async fn handle_case_detail(
|
||||
}
|
||||
|
||||
/// Locate a case directory under `<user_root>/<case_id>/`. Returns `None`
|
||||
/// if the directory does not exist (treated as a 404 / IDOR probe by callers).
|
||||
/// if the directory does not exist OR is soft-deleted (`.deleted` marker
|
||||
/// present). Both are treated as 404 / IDOR probe by callers.
|
||||
pub(crate) async fn locate_case(user_root: &Path, case_id: &str) -> Option<std::path::PathBuf> {
|
||||
let p = user_root.join(case_id);
|
||||
if tokio::fs::try_exists(&p).await.unwrap_or(false) {
|
||||
Some(p)
|
||||
} else {
|
||||
None
|
||||
if !tokio::fs::try_exists(&p).await.unwrap_or(false) {
|
||||
return None;
|
||||
}
|
||||
if crate::paths::is_deleted(&p).await {
|
||||
return None;
|
||||
}
|
||||
Some(p)
|
||||
}
|
||||
|
||||
/// Scan all of the given user's cases. Returned vec is sorted by most
|
||||
|
||||
Reference in New Issue
Block a user