mirror of
https://github.com/filecoffee/filehost.git
synced 2024-11-13 19:49:56 +01:00
local gather statistics
This commit is contained in:
parent
317848ec0b
commit
bffa3a1814
1 changed files with 16 additions and 1 deletions
|
@ -38,7 +38,22 @@ const initializeLocalStorage = (multerOptions, fileNameLength, uploadPath) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return { writeFile, findFile };
|
const gatherStatistics = () => {
|
||||||
|
let totalUploads = 0;
|
||||||
|
let totalSize = 0;
|
||||||
|
|
||||||
|
const files = fs.readdirSync(uploadPath);
|
||||||
|
files.forEach((file) => {
|
||||||
|
const filePath = path.join(uploadPath, file);
|
||||||
|
const stats = fs.statSync(filePath);
|
||||||
|
totalUploads++;
|
||||||
|
totalSize += stats.size;
|
||||||
|
});
|
||||||
|
|
||||||
|
return { totalUploads, totalSize };
|
||||||
|
};
|
||||||
|
|
||||||
|
return { writeFile, findFile, gatherStatistics };
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = initializeLocalStorage;
|
module.exports = initializeLocalStorage;
|
||||||
|
|
Loading…
Reference in a new issue