|
@ -47,7 +47,7 @@ class FileService { |
|
|
deleteOldFiles() { |
|
|
deleteOldFiles() { |
|
|
const directoryPath = path.join(basedir, 'public/csv'); |
|
|
const directoryPath = path.join(basedir, 'public/csv'); |
|
|
const files = fs.readdirSync(directoryPath); |
|
|
const files = fs.readdirSync(directoryPath); |
|
|
const oneDay = 24 * 60 * 60 * 1000; // Un jour en millisecondes
|
|
|
const oneDay = 48 * 60 * 60 * 1000; // Un jour en millisecondes
|
|
|
const currentDate = new Date(); |
|
|
const currentDate = new Date(); |
|
|
|
|
|
|
|
|
emitter.emit('deleteOldFiles.start', { files, directoryPath }); |
|
|
emitter.emit('deleteOldFiles.start', { files, directoryPath }); |
|
@ -76,14 +76,14 @@ class FileService { |
|
|
emitter.emit('checkLastOperationDate.start', { dateFilePath }); |
|
|
emitter.emit('checkLastOperationDate.start', { dateFilePath }); |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
const oneDay = 24 * 60 * 60 * 1000; // Un jour en millisecondes
|
|
|
const oneDay = 48 * 60 * 60 * 1000; // Un 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 - (2*oneDay)); |
|
|
const twodaysdate = new Date(currentDate - (1.5*oneDay)); |
|
|
fs.writeFileSync(dateFilePath, twodaysdate.toISOString(), 'utf-8'); |
|
|
fs.writeFileSync(dateFilePath, twodaysdate.toISOString(), 'utf-8'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|