bugfix
This commit is contained in:
parent
90a2f48102
commit
28cbe48793
@ -72,13 +72,15 @@ class UserEndpoint extends ApiEndpoint {
|
||||
const x = file.name.split('.');
|
||||
const fileName = `${user.id}.${x[x.length - 1]}`;
|
||||
const avatarsDir = path.resolve(this.server.serveFiles, 'avatars');
|
||||
const oldAvatar = path.join(avatarsDir, user.avatar);
|
||||
if (!fs.statSync(avatarsDir))
|
||||
fs.mkdirSync(avatarsDir);
|
||||
|
||||
// Delete old avatar
|
||||
if (user.avatar) {
|
||||
const oldAvatar = path.join(avatarsDir, user.avatar);
|
||||
if (fs.statSync(oldAvatar))
|
||||
fs.unlinkSync(oldAvatar);
|
||||
}
|
||||
|
||||
file.mv(path.join(avatarsDir, fileName), async (err) => {
|
||||
if (err) {
|
||||
|
Loading…
Reference in New Issue
Block a user