refactor: reduce number of intermediate arrays

This commit is contained in:
siiky 2024-07-03 17:25:13 +01:00
parent 1451f78211
commit 7ab44602ee

View file

@ -195,10 +195,8 @@ const cleanOldFailedQRScans = () => {
readdirRec(path.join(OPERATOR_DATA_DIR, 'failedQRScans'))
.then(entries => Promise.all(
entries
.filter(entry => entry.isFile())
.map(entry => entry.path)
.filter(isOld)
.map(fs.unlink)
.filter(entry => entry.isFile() && isOld(entry.path))
.map(entry => fs.unlink(entry.path))
))
.catch(err => {
console.log("Error cleaning up failed QR scans:", err)