mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36: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 userPicRegex = /^\d+-profile/;
|
||||
const files = (await fs.promises.readdir(folder, { withFileTypes: true }))
|
||||
.filter(item => !item.isDirectory() && String(item.name).match(userPicRegex))
|
||||
.map(item => item.name);
|
||||
let files = [];
|
||||
try {
|
||||
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;
|
||||
await batch.processArray(files, async (files) => {
|
||||
|
||||
Reference in New Issue
Block a user