note to self don't use statsync

This commit is contained in:
Erik 2023-02-07 23:18:48 +02:00
parent 28cbe48793
commit 28cf479e4b
Signed by: Navy.gif
GPG Key ID: 2532FBBB61C65A68

View File

@ -72,13 +72,13 @@ class UserEndpoint extends ApiEndpoint {
const x = file.name.split('.'); const x = file.name.split('.');
const fileName = `${user.id}.${x[x.length - 1]}`; const fileName = `${user.id}.${x[x.length - 1]}`;
const avatarsDir = path.resolve(this.server.serveFiles, 'avatars'); const avatarsDir = path.resolve(this.server.serveFiles, 'avatars');
if (!fs.statSync(avatarsDir)) if (!fs.existsSync(avatarsDir))
fs.mkdirSync(avatarsDir); fs.mkdirSync(avatarsDir);
// Delete old avatar // Delete old avatar
if (user.avatar) { if (user.avatar) {
const oldAvatar = path.join(avatarsDir, user.avatar); const oldAvatar = path.join(avatarsDir, user.avatar);
if (fs.statSync(oldAvatar)) if (fs.existsSync(oldAvatar))
fs.unlinkSync(oldAvatar); fs.unlinkSync(oldAvatar);
} }