mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: don't crash if profile folder doesn't exist
This commit is contained in:
@@ -19,9 +19,15 @@ module.exports = {
|
|||||||
const folder = path.join(nconf.get('upload_path'), 'profile');
|
const folder = path.join(nconf.get('upload_path'), 'profile');
|
||||||
|
|
||||||
const userPicRegex = /^\d+-profile/;
|
const userPicRegex = /^\d+-profile/;
|
||||||
const files = (await fs.promises.readdir(folder, { withFileTypes: true }))
|
let files = [];
|
||||||
.filter(item => !item.isDirectory() && String(item.name).match(userPicRegex))
|
try {
|
||||||
.map(item => item.name);
|
files = (await fs.promises.readdir(folder, { withFileTypes: true }))
|
||||||
|
.filter(item => !item.isDirectory() && String(item.name).match(userPicRegex))
|
||||||
|
.map(item => item.name);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err.stack);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
progress.total = files.length;
|
progress.total = files.length;
|
||||||
await batch.processArray(files, async (files) => {
|
await batch.processArray(files, async (files) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user