add the 5 minute difference back and clean

merge-requests/208/head
fatchan 5 years ago
parent 4bf56fdc3b
commit 9c99b9026c
  1. 11
      schedules.js

@ -17,17 +17,12 @@ async function deleteCaptchas() {
const filePath = `${uploadDirectory}captcha/${file}`;
const stats = await stat(filePath);
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) {
await remove(filePath);
console.log(`Deleted expired captcha ${filePath}`)
}
} 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);
}
});
@ -41,15 +36,13 @@ async function deleteCaptchas() {
console.log('Starting schedules');
buildHomepage()
deleteCaptchas();
setInterval(async () => {
try {
await buildHomepage();
} catch (e) {
console.error(e);
}
}, msTime.hour); //hourly rebuild homepage for posts/day
}, msTime.minute*5); //rebuild homepage for pph updates
setInterval(async () => {
try {

Loading…
Cancel
Save