feat(ui): aggiunge barra di progresso durante lo smistamento

Mostra una progress bar con messaggio contestuale nelle 4 fasi:
scansione sorgente, analisi cartella destinazione (con contatore
cartelle), ricerca duplicati (con contatore file CAD), smistamento
(N / totale). La barra è indeterminata nelle prime tre fasi e
determinata durante la copia. Il canale IPC progress viene
aperto all'inizio e chiuso al termine dell'operazione
This commit is contained in:
2026-03-16 14:54:23 +01:00
parent 57f8b230b2
commit b0bcea2f10
8 changed files with 133 additions and 19 deletions

View File

@@ -4,13 +4,15 @@ const path = require('path');
const CODE_FOLDER_REGEX = /^\d{3}$/;
const MAX_SCAN_DEPTH = 6;
async function buildDestinationIndex(destinationRoot) {
async function buildDestinationIndex(destinationRoot, onProgress) {
const index = new Map();
if (!destinationRoot || !(await fs.pathExists(destinationRoot))) {
return index;
}
let scanned = 0;
async function walk(currentDir, depth) {
if (depth > MAX_SCAN_DEPTH) {
return;
@@ -29,6 +31,9 @@ async function buildDestinationIndex(destinationRoot) {
}
const fullPath = path.join(currentDir, entry.name);
scanned += 1;
onProgress?.({ phase: 'index-dest', scanned, folder: entry.name });
if (CODE_FOLDER_REGEX.test(entry.name)) {
const rows = index.get(entry.name) || [];
rows.push(fullPath);