mirror of
https://codeberg.org/teddit/teddit
synced 2025-02-01 20:07:21 +01:00
use 24 hours interval if the interval value (config.cache_control_interval) is set to over 1000. fixes cache control for older config.cache_control_interval values
This commit is contained in:
parent
01c41c7adf
commit
265c33fcd2
@ -2,26 +2,26 @@ module.exports.removeCacheFiles = function() {
|
||||
const config = require('./config');
|
||||
|
||||
async function deleteStatic() {
|
||||
const fs = require('fs');
|
||||
const pics = './static/pics/';
|
||||
const vids = './static/vids/';
|
||||
const fs = require('fs');
|
||||
const pics = './static/pics/';
|
||||
const vids = './static/vids/';
|
||||
|
||||
fs.rmdir(pics, { recursive: true, force: true }, () => {
|
||||
fs.rmdir(vids, { recursive: true, force: true }, () => {
|
||||
['pics/thumbs', 'pics/flairs', 'pics/icons', 'vids'].map((d) => `./static/${d}`)
|
||||
.filter((d) => !fs.existsSync(d))
|
||||
.forEach((d) => fs.mkdirSync(d, { recursive: true }));
|
||||
fs.rmdir(pics, { recursive: true, force: true }, () => {
|
||||
fs.rmdir(vids, { recursive: true, force: true }, () => {
|
||||
['pics/thumbs', 'pics/flairs', 'pics/icons', 'vids'].map((d) => `./static/${d}`)
|
||||
.filter((d) => !fs.existsSync(d))
|
||||
.forEach((d) => fs.mkdirSync(d, { recursive: true }));
|
||||
|
||||
console.log('Cleared cached static media files. You can turn this off by setting the config.cache_control to false.');
|
||||
});
|
||||
console.log('Cleared cached static media files. You can turn this off by setting the config.cache_control to false.');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if(config.cache_control) {
|
||||
deleteStatic();
|
||||
|
||||
const hours = config.cache_control_interval;
|
||||
if (hours < 1 || isNaN(hours)) {
|
||||
let hours = config.cache_control_interval;
|
||||
if (hours < 1 || hours > 10000 || isNaN(hours)) {
|
||||
hours = 24;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user