From ef23a7119e72e497273bb2592a3c993a6c793033 Mon Sep 17 00:00:00 2001 From: MasutaYunikon Date: Fri, 10 Apr 2026 21:03:57 +0200 Subject: [PATCH] fix: ajout de logs lors de non match --- server/organize.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/server/organize.ts b/server/organize.ts index a9525c8..6248333 100644 --- a/server/organize.ts +++ b/server/organize.ts @@ -139,10 +139,16 @@ export async function scanMediaPath( walk(full) } else if (entry.isFile() && /\.(mkv|mp4|avi|m4v|mov|wmv)$/i.test(entry.name)) { result.found++ - // Chercher par nom sans extension pour matcher quelle que soit l'extension const nameWithoutExt = entry.name.replace(/\.[^.]+$/, '') const match = filenameIndex.get(nameWithoutExt) - if (!match) continue + if (!match) { + // Trouver des candidats proches dans l'index (même début de nom) + const prefix = nameWithoutExt.slice(0, 20).toLowerCase() + const close = [...filenameIndex.keys()].filter(k => k.toLowerCase().startsWith(prefix)).slice(0, 3) + const closeStr = close.length > 0 ? ` | candidats : ${close.map(c => `"${c}"`).join(', ')}` : ' | aucun candidat proche' + logger.warn('organize', `Scan no match : "${nameWithoutExt}"${closeStr}`) + continue + } const { hash, srcFilename, episodeId, season, episode } = match // Le destFilename prend l'extension réelle du fichier sur le disque @@ -187,11 +193,11 @@ export async function scanMediaPath( if (result.added > 0 || removed > 0) { fs.writeFileSync(organizedPath, JSON.stringify(organized, null, 2), 'utf-8') - logger.info('organize', `Scan terminé — ${result.found} fichiers, ${result.added} ajoutés, ${removed} orphelins supprimés`) - } else { - logger.info('organize', `Scan terminé — ${result.found} fichiers, rien de nouveau`) } + const noMatch = result.found - result.added + logger.info('organize', `Scan terminé — ${result.found} fichiers, ${result.added} ajoutés, ${removed} orphelins supprimés${noMatch > 0 ? `, ${noMatch} non matchés` : ''}`) + return result }