From b82a71b9e70cc6a79c7bd8a2307bfb50b42b3e13 Mon Sep 17 00:00:00 2001 From: unfr Date: Wed, 13 Aug 2025 21:58:04 +0200 Subject: [PATCH] Amelioration auto-update --- autopost/server.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/autopost/server.js b/autopost/server.js index c0f24df..e610672 100644 --- a/autopost/server.js +++ b/autopost/server.js @@ -126,7 +126,7 @@ const LP_TIMEOUT_MS = 25000; function lpNotify(source, filePath) { lpVersion += 1; - console.log('[LP] notify', { version: lpVersion, source, file: filePath }); + //console.log('[LP] notify', { version: lpVersion, source, file: filePath }); for (const waiter of lpWaiters) { clearTimeout(waiter.timer); try { waiter.res.json({ version: lpVersion }); } catch (_) {} @@ -159,12 +159,13 @@ autopostRouter.get('/updates', (req, res) => { }); // Watcher fichiers (JSON / BDINFO) + fallback scan -const infoDir = path.resolve(config.infodirectory); +const infoDir = path.resolve(config.logdirectory); const watchPatterns = [ path.join(infoDir, '*.json'), path.join(infoDir, '*.JSON'), path.join(infoDir, '*.bdinfo.txt'), - path.join(infoDir, '*.BDINFO.TXT') + path.join(infoDir, '*.BDINFO.TXT'), + path.join(infoDir, '*.log') ]; const lpWatcher = chokidar.watch(watchPatterns, { @@ -179,7 +180,7 @@ const lpWatcher = chokidar.watch(watchPatterns, { lpWatcher.on('add', (filePath) => lpNotify('add', filePath)); lpWatcher.on('change', (filePath) => lpNotify('change', filePath)); -lpWatcher.on('ready', () => console.log('[LP] watcher ready on', watchPatterns)); +//lpWatcher.on('ready', () => console.log('[LP] watcher ready on', watchPatterns)); lpWatcher.on('error', (err) => console.error('[LP] watcher error:', err)); // Fallback scan (toutes les 2s) : signature (nb fichiers + dernier mtime) @@ -189,7 +190,7 @@ let lastSig = null; async function computeSignature() { try { const names = await fsp.readdir(infoDir); - const files = names.filter(n => /\.json$/i.test(n) || /\.bdinfo\.txt$/i.test(n)); + const files = names.filter(n => /(?:\.json|\.log|\.bdinfo\.txt)$/i.test(n)); let latest = 0; await Promise.all(files.map(async (n) => { try { @@ -423,7 +424,7 @@ autopostRouter.get('/', async (req, res) => { default: statusText = 'INCONNU'; } - let logLink = (parseInt(row.status) === 1 || parseInt(row.status) === 2) + let logLink = (parseInt(row.status) === 1 || parseInt(row.status) === 2 || parseInt(row.status) === 4) ? ' | Log' : ''; let mediainfoLink = (parseInt(row.status) === 0 || parseInt(row.status) === 1 || parseInt(row.status) === 2)