feat(router): instrada in sottocartella A/M_B e ottimizza cache destinazione

- Router: aggiunge campo `subfolder` a getCadInfo (91xxxxx → A, 92xxxxx → M_B);
  getDestinationDecision appende la sottocartella al percorso finale
- Scanner (fast path): legge A e M_B dentro ogni cartella a 3 cifre per
  il rilevamento duplicati, anziché la cartella a 3 cifre stessa
- Cache: persistenza su disco del folderIndex; cadKeyIndex sempre fresco
- isCacheStillValid: validazione a due livelli (top-level + cartelle a 3
  cifre) — rileva automaticamente nuove cartelle aggiunte da colleghi
- UI: rimosso pulsante "Riscansiona destinazione"; gestione cache completamente
  automatica e trasparente per l'utente
This commit is contained in:
2026-03-16 16:17:24 +01:00
parent a49d338741
commit 65b1777a60
4 changed files with 204 additions and 23 deletions

View File

@@ -35,19 +35,34 @@ function hideProgress() {
let _indexFilesFound = 0;
function updateProgress({ phase, current, total, file, scanned, folder }) {
if (phase === 'scan') {
if (phase === 'index-cache') {
// folderIndex dalla cache — avvia scansione veloce dei file
progressBar.max = total || 1;
progressBar.value = 0;
progressLabel.textContent = 'Struttura dalla cache — ricerca file CAD in corso...';
return;
} else if (phase === 'scan') {
_indexFilesFound = 0;
progressLabel.textContent = 'Scansione file sorgente...';
progressBar.removeAttribute('value');
} else if (phase === 'index-dest') {
// scansione completa (nessuna cache)
progressBar.max = total;
progressBar.value = current;
const filesInfo = _indexFilesFound > 0 ? `${_indexFilesFound} file CAD trovati` : '';
progressLabel.textContent = `Analisi destinazione: ${current} / ${total}${folder ? `${folder}` : ''}${filesInfo}`;
} else if (phase === 'index-dup') {
_indexFilesFound = scanned;
const dirInfo = progressBar.max > 0 ? `${progressBar.value} / ${progressBar.max}` : '';
progressLabel.textContent = `Analisi destinazione: ${dirInfo}${scanned} file CAD trovati`;
if (current !== undefined && total !== undefined) {
// scansione veloce (cache attiva): current/total = cartelle processate
progressBar.max = total;
progressBar.value = current;
progressLabel.textContent = `Ricerca file CAD: ${current} / ${total} cartelle`;
} else {
// scansione completa: scanned = contatore file trovati
_indexFilesFound = scanned;
const dirInfo = progressBar.max > 0 ? `${progressBar.value} / ${progressBar.max}` : '';
progressLabel.textContent = `Analisi destinazione: ${dirInfo}${scanned} file CAD trovati`;
}
} else if (phase === 'copy') {
progressBar.max = total;
progressBar.value = current;
@@ -349,6 +364,7 @@ clearPreviewBtn.addEventListener('click', async () => {
}
});
closePreviewBtn.addEventListener('click', hidePreview);
previewOverlay.addEventListener('click', (event) => {
if (event.target === previewOverlay) {