mirror of
https://github.com/Metastem/wikiless
synced 2024-12-06 19:16:58 +01:00
revert
Build docker image / docker (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Deploy Jekyll with GitHub Pages dependencies preinstalled / build (push) Has been cancelled
Deploy Jekyll with GitHub Pages dependencies preinstalled / deploy (push) Has been cancelled
Build docker image / docker (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Deploy Jekyll with GitHub Pages dependencies preinstalled / build (push) Has been cancelled
Deploy Jekyll with GitHub Pages dependencies preinstalled / deploy (push) Has been cancelled
currently not able to test, i forgot to do that instead. not at my regular setup right now so my bad for that!
This commit is contained in:
+12
-21
@@ -1,29 +1,20 @@
|
|||||||
const fs = require('fs/promises'); // Use promises for better handling
|
module.exports.removeCacheFiles = function() {
|
||||||
const path = require('path');
|
const config = require('../config');
|
||||||
const config = require('../config');
|
|
||||||
|
|
||||||
async function deleteStatic() {
|
async function deleteStatic() {
|
||||||
const wiki_files = path.resolve(__dirname, '../media/wikipedia'); // Resolve relative path
|
const fs = require('fs');
|
||||||
|
const wiki_files = './media/wikipedia/';
|
||||||
|
|
||||||
try {
|
fs.rm(wiki_files, { recursive: true, force: true }, () => {
|
||||||
await fs.rm(wiki_files, { recursive: true, force: 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.'
|
|
||||||
);
|
|
||||||
} catch (error) {
|
|
||||||
console.error(`Error clearing cached static media files: ${error.message}`);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
module.exports.removeCacheFiles = function () {
|
if(config.cache_control) {
|
||||||
if (config.cache_control) {
|
|
||||||
deleteStatic();
|
deleteStatic();
|
||||||
|
|
||||||
let hours = parseInt(config.cache_control_interval, 10);
|
let hours = config.cache_control_interval;
|
||||||
if (isNaN(hours) || hours < 1) {
|
if (hours < 1 || isNaN(hours)) {
|
||||||
console.warn(
|
|
||||||
'Invalid cache_control_interval. Defaulting to 24 hours.'
|
|
||||||
);
|
|
||||||
hours = 24;
|
hours = 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,4 +22,4 @@ module.exports.removeCacheFiles = function () {
|
|||||||
deleteStatic();
|
deleteStatic();
|
||||||
}, 1000 * 60 * 60 * hours);
|
}, 1000 * 60 * 60 * hours);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user