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

@@ -66,10 +66,12 @@ async function collectFilesRecursively(rootDir) {
return files;
}
async function processFolder(folder, config) {
async function processFolder(folder, config, onProgress) {
onProgress?.({ phase: 'scan' });
const files = await collectFilesRecursively(folder);
const destinationIndex = await buildDestinationIndex(config?.destination);
const existingCadKeys = await buildExistingCadKeyIndex(config?.destination);
const destinationIndex = await buildDestinationIndex(config?.destination, onProgress);
const existingCadKeys = await buildExistingCadKeyIndex(config?.destination, onProgress);
const sourceMaxVersions = buildHighestNumericVersionByCadKey(files);
const result = {
scanned: 0,
@@ -80,9 +82,13 @@ async function processFolder(folder, config) {
details: [],
};
for (const { fullPath, fileName } of files) {
const total = files.length;
for (let i = 0; i < files.length; i++) {
const { fullPath, fileName } = files[i];
const file = fileName;
result.scanned += 1;
onProgress?.({ phase: 'copy', current: i + 1, total, file });
const cadInfo = getCadInfo(file);
if (!cadInfo) {