feat(indexer,backoffice): ajouter warnings dans les stats de job, skip fichiers inaccessibles

- Indexer: ajout du champ `warnings` dans JobStats pour les erreurs
  non-fatales (fichiers inaccessibles, permissions)
- Indexer: skip les fichiers dont le stat échoue au lieu de faire
  crasher tout le scan de la library
- Backoffice: affichage des warnings dans le détail job (summary,
  timeline, Index Statistics) et dans la popin jobs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-13 13:44:48 +01:00
parent f71ca92e85
commit fe54f55f47
5 changed files with 22 additions and 5 deletions

View File

@@ -19,6 +19,7 @@ interface Job {
scanned_files: number;
indexed_files: number;
errors: number;
warnings: number;
} | null;
}
@@ -261,8 +262,11 @@ export function JobsIndicator() {
{job.stats_json && (
<div className="flex items-center gap-3 mt-1.5 text-xs text-muted-foreground">
<span> {job.stats_json.indexed_files}</span>
{(job.stats_json.warnings ?? 0) > 0 && (
<span className="text-warning"> {job.stats_json.warnings}</span>
)}
{job.stats_json.errors > 0 && (
<span className="text-destructive"> {job.stats_json.errors}</span>
<span className="text-destructive"> {job.stats_json.errors}</span>
)}
</div>
)}

View File

@@ -30,6 +30,7 @@ interface JobDetails {
indexed_files: number;
removed_files: number;
errors: number;
warnings: number;
} | null;
error_opt: string | null;
}
@@ -182,6 +183,7 @@ export default async function JobDetailPage({ params }: JobDetailPageProps) {
<span className="ml-2 text-success/80">
{job.stats_json.scanned_files} scanned, {job.stats_json.indexed_files} indexed
{job.stats_json.removed_files > 0 && `, ${job.stats_json.removed_files} removed`}
{(job.stats_json.warnings ?? 0) > 0 && `, ${job.stats_json.warnings} warnings`}
{job.stats_json.errors > 0 && `, ${job.stats_json.errors} errors`}
{job.total_files != null && job.total_files > 0 && `, ${job.total_files} thumbnails`}
</span>
@@ -312,6 +314,7 @@ export default async function JobDetailPage({ params }: JobDetailPageProps) {
<span className="text-muted-foreground font-normal ml-1">
· {job.stats_json.scanned_files} scanned, {job.stats_json.indexed_files} indexed
{job.stats_json.removed_files > 0 && `, ${job.stats_json.removed_files} removed`}
{(job.stats_json.warnings ?? 0) > 0 && `, ${job.stats_json.warnings} warn`}
</span>
)}
</p>
@@ -462,10 +465,11 @@ export default async function JobDetailPage({ params }: JobDetailPageProps) {
)}
</CardHeader>
<CardContent>
<div className="grid grid-cols-2 sm:grid-cols-4 gap-4">
<div className="grid grid-cols-2 sm:grid-cols-5 gap-4">
<StatBox value={job.stats_json.scanned_files} label="Scanned" variant="success" />
<StatBox value={job.stats_json.indexed_files} label="Indexed" variant="primary" />
<StatBox value={job.stats_json.removed_files} label="Removed" variant="warning" />
<StatBox value={job.stats_json.warnings ?? 0} label="Warnings" variant={(job.stats_json.warnings ?? 0) > 0 ? "warning" : "default"} />
<StatBox value={job.stats_json.errors} label="Errors" variant={job.stats_json.errors > 0 ? "error" : "default"} />
</div>
</CardContent>

View File

@@ -25,6 +25,7 @@ export type IndexJobDto = {
indexed_files: number;
removed_files: number;
errors: number;
warnings: number;
} | null;
progress_percent: number | null;
processed_files: number | null;

View File

@@ -292,6 +292,7 @@ pub async fn process_job(
indexed_files: 0,
removed_files: 0,
errors: 0,
warnings: 0,
};
let mut total_processed_count = 0i32;

View File

@@ -1,4 +1,4 @@
use anyhow::{Context, Result};
use anyhow::Result;
use chrono::{DateTime, Utc};
use parsers::{detect_format, parse_metadata_fast};
use serde::Serialize;
@@ -21,6 +21,7 @@ pub struct JobStats {
pub indexed_files: usize,
pub removed_files: usize,
pub errors: usize,
pub warnings: usize,
}
const BATCH_SIZE: usize = 100;
@@ -205,8 +206,14 @@ pub async fn scan_library_discovery(
.map(|s| s.to_string_lossy().to_string())
.unwrap_or_else(|| abs_path.clone());
let metadata = std::fs::metadata(&path)
.with_context(|| format!("cannot stat {}", path.display()))?;
let metadata = match std::fs::metadata(&path) {
Ok(m) => m,
Err(e) => {
warn!("[SCAN] cannot stat {}, skipping: {}", path.display(), e);
stats.warnings += 1;
continue;
}
};
let mtime: DateTime<Utc> = metadata
.modified()
.map(DateTime::<Utc>::from)