|
@ -76,15 +76,16 @@ class FileService { |
|
|
emitter.emit('checkLastOperationDate.start', { dateFilePath }); |
|
|
emitter.emit('checkLastOperationDate.start', { dateFilePath }); |
|
|
|
|
|
|
|
|
try { |
|
|
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(); |
|
|
const currentDate = new Date(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Check if file exists and create it if not with a default date of 48 hours ago
|
|
|
// Check if file exists and create it if not with a default date of 48 hours ago
|
|
|
if (!fs.existsSync(dateFilePath)) { |
|
|
if (!fs.existsSync(dateFilePath)) { |
|
|
emitter.emit('checkLastOperationDate.created', { dateFilePath }); |
|
|
emitter.emit('checkLastOperationDate.created', { dateFilePath }); |
|
|
const twodaysdate = new Date(currentDate - (1.5*oneDay)); |
|
|
const defaultFiledate = new Date(currentDate - (fileDate)); // 6 jours avant la date actuelle
|
|
|
fs.writeFileSync(dateFilePath, twodaysdate.toISOString(), 'utf-8'); |
|
|
fs.writeFileSync(dateFilePath, defaultFiledate.toISOString(), 'utf-8'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const lastOperationDate = fs.readFileSync(dateFilePath, 'utf-8'); |
|
|
const lastOperationDate = fs.readFileSync(dateFilePath, 'utf-8'); |
|
|