|
|
@ -17,17 +17,12 @@ async function deleteCaptchas() { |
|
|
|
const filePath = `${uploadDirectory}captcha/${file}`; |
|
|
|
const filePath = `${uploadDirectory}captcha/${file}`; |
|
|
|
const stats = await stat(filePath); |
|
|
|
const stats = await stat(filePath); |
|
|
|
const now = Date.now(); |
|
|
|
const now = Date.now(); |
|
|
|
const expiry = new Date(stats.ctime).getTime()// + msTime.minute*5;
|
|
|
|
const expiry = new Date(stats.ctime).getTime() + msTime.minute*5; |
|
|
|
if (now > expiry) { |
|
|
|
if (now > expiry) { |
|
|
|
await remove(filePath); |
|
|
|
await remove(filePath); |
|
|
|
console.log(`Deleted expired captcha ${filePath}`) |
|
|
|
console.log(`Deleted expired captcha ${filePath}`) |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
/* |
|
|
|
|
|
|
|
catching here to still get the error, but it wont reject the promise |
|
|
|
|
|
|
|
returned by deleteCaptchas, since this is anon async function in the |
|
|
|
|
|
|
|
foreach loop. this way we dont stop deleting captchas if only one fails |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
console.error(e); |
|
|
|
console.error(e); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -41,15 +36,13 @@ async function deleteCaptchas() { |
|
|
|
|
|
|
|
|
|
|
|
console.log('Starting schedules'); |
|
|
|
console.log('Starting schedules'); |
|
|
|
|
|
|
|
|
|
|
|
buildHomepage() |
|
|
|
|
|
|
|
deleteCaptchas(); |
|
|
|
|
|
|
|
setInterval(async () => { |
|
|
|
setInterval(async () => { |
|
|
|
try { |
|
|
|
try { |
|
|
|
await buildHomepage(); |
|
|
|
await buildHomepage(); |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
console.error(e); |
|
|
|
console.error(e); |
|
|
|
} |
|
|
|
} |
|
|
|
}, msTime.hour); //hourly rebuild homepage for posts/day
|
|
|
|
}, msTime.minute*5); //rebuild homepage for pph updates
|
|
|
|
|
|
|
|
|
|
|
|
setInterval(async () => { |
|
|
|
setInterval(async () => { |
|
|
|
try { |
|
|
|
try { |
|
|
|