get upload limit to work

This commit is contained in:
b1ek 2023-03-04 15:52:51 +10:00
parent df0dbf281c
commit a108d24f0f
Signed by: blek
GPG Key ID: 14546221E3595D0C
1 changed files with 12 additions and 17 deletions

View File

@ -6,8 +6,7 @@ const glob = require('glob');
const root = path.join(process.cwd(), '/usercontent'); const root = path.join(process.cwd(), '/usercontent');
const { MAXFILES } = process.env; const { MAXFILES } = process.env;
console.log(root); // console.log(root);
let initalized = false; let initalized = false;
@ -15,21 +14,17 @@ let submitted = 0;
async function init() { async function init() {
if (initalized) return; if (initalized) return;
glob(root + '/**', undefined, (err, files) => {
if (err) { let files = await glob(root + '/*');
console.error(err); files.filter(file => {return !file.startsWith('.')})
return; .forEach(file => {
}
files.filter(file => {
return !file.startsWith('.');
}).forEach(file => {
submitted++; submitted++;
}); return;
initalized = true;
}); });
} }
init();
function submitted() {return submitted;} function get_submitted() {return submitted;}
const make_id = () => { const make_id = () => {
return crypto.randomBytes(8).toString('hex'); return crypto.randomBytes(8).toString('hex');
@ -53,4 +48,4 @@ async function create(data) {
return id; return id;
} }
module.exports = { get, write, create, make_id, submitted }; module.exports = { get, write, create, make_id, submitted: get_submitted, init };