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