diff --git a/db.js b/db.js index 037e842..10b2f75 100644 --- a/db.js +++ b/db.js @@ -8,16 +8,16 @@ const client = new Client({ database: 'timelapse' }); -function connectWithRetry() { +function init_database() { client.connect(err => { if (err) { console.error('Erreur de connexion à la base de données:', err); - setTimeout(connectWithRetry, 30000); + setTimeout(init_database, 30000); } else { console.log('[DB] Connecté à la base de données PostgreSQL.'); } }); } -connectWithRetry(); +init_database(); module.exports = client; \ No newline at end of file diff --git a/src/data/filewatcher.js b/src/data/filewatcher.js index 8e8ed4c..0cd653a 100644 --- a/src/data/filewatcher.js +++ b/src/data/filewatcher.js @@ -16,9 +16,7 @@ async function checkAndRemoveInvalidEntries() { } } - // Scan all images in storage const allImages = await storageManager.scanAllImages(); - //console.log('Scanned all images:', allImages); for (const imagePath of allImages) { const entryRes = await db.query('SELECT id FROM measurements WHERE path = $1', [imagePath]); if (entryRes.rows.length === 0) { @@ -29,6 +27,7 @@ async function checkAndRemoveInvalidEntries() { } if (localCounter > 0) { console.log(`[INFO] ${localCounter} entrées ont été modifiées`); + localCounter = 0; // Reset the counter after logging } } catch (err) { console.error('Error checking and removing invalid entries:', err);