Refactor analysis file names
The versioning of analysis input and document files
(`analysis_input_v{N}.json`, `document_v{N}.md`) has been removed. All
analysis inputs will now use `analysis_input.json` and generated
documents will use `document.md`.
This simplifies file management, as there's no longer a need to track
and manage multiple versions of these files within a case directory. The
analysis worker will now overwrite the existing `document.md` if it
exists, ensuring that the latest analysis result is always present. The
`version` field has also been removed from `AnalyzeJob` and
`AnalysisInput`.
This commit is contained in:
@@ -8,12 +8,12 @@ use time::format_description::well_known::Rfc3339;
|
||||
use time::OffsetDateTime;
|
||||
use tracing::{info, warn};
|
||||
|
||||
use crate::analyze::{AnalyzeJob, AnalyzeSender};
|
||||
use crate::analyze::{AnalyzeJob, AnalyzeSender, ANALYSIS_INPUT_FILE, DOCUMENT_FILE};
|
||||
use crate::auth::AuthenticatedWebUser;
|
||||
use crate::config::Config;
|
||||
use crate::error::AppError;
|
||||
use crate::paths::{write_delete_marker, DeleteMarker};
|
||||
use crate::routes::case_actions::{build_analysis_input, find_latest_document, write_input_create_new};
|
||||
use crate::routes::case_actions::{build_analysis_input, write_input_create_new};
|
||||
use crate::routes::user_web::locate_case;
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
@@ -72,11 +72,19 @@ async fn bulk_analyze(
|
||||
skipped += 1;
|
||||
continue;
|
||||
};
|
||||
let version = find_latest_document(&case_dir)
|
||||
.await
|
||||
.map(|(v, _)| v + 1)
|
||||
.unwrap_or(1);
|
||||
let input = match build_analysis_input(&case_dir, version).await {
|
||||
// Same order as the single-case handler: drop old document first so
|
||||
// the UI doesn't keep showing "ausgewertet" during re-analysis.
|
||||
let document_path = case_dir.join(DOCUMENT_FILE);
|
||||
match tokio::fs::remove_file(&document_path).await {
|
||||
Ok(_) => {}
|
||||
Err(e) if e.kind() == std::io::ErrorKind::NotFound => {}
|
||||
Err(e) => {
|
||||
warn!(slug = %slug, case_id = %case_id, error = %e, "bulk-analyze: remove old document failed");
|
||||
skipped += 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
let input = match build_analysis_input(&case_dir).await {
|
||||
Ok(i) => i,
|
||||
Err(_) => {
|
||||
warn!(slug = %slug, case_id = %case_id, "bulk-analyze: build_analysis_input failed");
|
||||
@@ -84,7 +92,7 @@ async fn bulk_analyze(
|
||||
continue;
|
||||
}
|
||||
};
|
||||
let input_path = case_dir.join(format!("analysis_input_v{version}.json"));
|
||||
let input_path = case_dir.join(ANALYSIS_INPUT_FILE);
|
||||
if write_input_create_new(&input_path, &input).await.is_err() {
|
||||
warn!(slug = %slug, case_id = %case_id, "bulk-analyze: write input failed");
|
||||
skipped += 1;
|
||||
@@ -93,7 +101,6 @@ async fn bulk_analyze(
|
||||
if analyze_tx
|
||||
.send(AnalyzeJob {
|
||||
case_dir: case_dir.clone(),
|
||||
version,
|
||||
})
|
||||
.is_err()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user