From 79d3e8c3916c03262ab0472f73d683a94219081f Mon Sep 17 00:00:00 2001 From: Onja Date: Wed, 25 Oct 2023 19:30:53 +0300 Subject: [PATCH] Set default file date to 6 days ago if file does not exist --- src/services/file.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/services/file.js b/src/services/file.js index 94001f1..ccedbfa 100644 --- a/src/services/file.js +++ b/src/services/file.js @@ -76,15 +76,16 @@ class FileService { emitter.emit('checkLastOperationDate.start', { dateFilePath }); try { - const oneDay = 48 * 60 * 60 * 1000; // Un jour en millisecondes + const oneDay = 5 * 24 * 60 * 60 * 1000; // 5 jour en millisecondes + const fileDate = 6 * 24 * 60 * 60 * 1000; // 6 jour en millisecondes const currentDate = new Date(); // Check if file exists and create it if not with a default date of 48 hours ago if (!fs.existsSync(dateFilePath)) { emitter.emit('checkLastOperationDate.created', { dateFilePath }); - const twodaysdate = new Date(currentDate - (1.5*oneDay)); - fs.writeFileSync(dateFilePath, twodaysdate.toISOString(), 'utf-8'); + const defaultFiledate = new Date(currentDate - (fileDate)); // 6 jours avant la date actuelle + fs.writeFileSync(dateFilePath, defaultFiledate.toISOString(), 'utf-8'); } const lastOperationDate = fs.readFileSync(dateFilePath, 'utf-8');