1
0

Amelioration auto-update

This commit is contained in:
unfr 2025-08-13 21:58:04 +02:00
parent 0ea759b490
commit b82a71b9e7

View File

@ -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)
? ' | <a href="#" class="log-link text-blue-400 hover:underline" data-filename="' + row.nom + '">Log</a>'
: '';
let mediainfoLink = (parseInt(row.status) === 0 || parseInt(row.status) === 1 || parseInt(row.status) === 2)