Skip to content

Commit

Permalink
fix: adds cleanup for reclassified layer
Browse files Browse the repository at this point in the history
  • Loading branch information
FritzHoing committed Feb 27, 2024
1 parent fb4311d commit b3d3753
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/dataset-archive/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,25 @@ const archiveWorker = async (workerJob, inputs) => {
}
}));
}

// 4. do the same thing for reclassified files
const reclassifiedFiles = fs.readdirSync(`${finalDatadir}/${region}/${region}_reclassified/`);
const reclassifiedTimestamps = reclassifiedFiles.map((element) => dayjs.utc(element.match(regex)[2], 'YYYYMMDDTHHmmZ').startOf('hour'));
// 2. get timestamps that are older than 49 hours
const reclassifiedTimestampsToDelete = reclassifiedTimestamps.filter(timestamp => timestamp < currentTimestamp.subtract(49, 'hours'));
// 3. create list of timestamps to delete

// todo: hier fehlen noch die potentiellen tmp dateien!
const reclassifiedFilesToDelete = reclassifiedTimestampsToDelete.map((timestamp) => `${finalDatadir}/${region}/${region}_reclassified/${region}_${timestamp.format('YYYYMMDDTHHmm')}Z.tif`);

for (const file of reclassifiedFilesToDelete) {
await fs.unlink(file, (err => {
if (err) logger.error(err);
else {
logger.info('Deleted file:', file)
}
}));
}
}

try {
Expand Down

0 comments on commit b3d3753

Please sign in to comment.