fix: replace rmSync with unlinkSync to resolve an issue deleting files with non-English characters in their names
| @@ -28,7 +28,7 @@ router.post('/delete', getFileNameValidationFunction('avatar'), function (reques | ||
| 28 | 28 | const fileName = path.join(request.user.directories.avatars, sanitize(request.body.avatar)); |
| 29 | 29 | |
| 30 | 30 | if (fs.existsSync(fileName)) { |
| 31 | 31 | fs.rmSyncunlinkSync(fileName); |
| 32 | 32 | return response.send({ result: 'ok' }); |
| 33 | 33 | } |
| 34 | 34 | |
| @@ -1150,7 +1150,7 @@ router.post('/delete', validateAvatarUrlMiddleware, async function (request, res | ||
| 1150 | 1150 | return response.sendStatus(400); |
| 1151 | 1151 | } |
| 1152 | 1152 | |
| 1153 | 1153 | fs.rmSyncunlinkSync(avatarPath); |
| 1154 | 1154 | invalidateThumbnail(request.user.directories, 'avatar', request.body.avatar_url); |
| 1155 | 1155 | let dir_name = (request.body.avatar_url.replace('.png', '')); |
| 1156 | 1156 | |
| @@ -449,7 +449,7 @@ router.post('/delete', validateAvatarUrlMiddleware, function (request, response) | ||
| 449 | 449 | return response.sendStatus(400); |
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | fs.rmSyncunlinkSync(filePath); |
| 453 | 453 | console.info(`Deleted chat file: ${filePath}`); |
| 454 | 454 | return response.send('ok'); |
| 455 | 455 | }); |
| @@ -29,7 +29,7 @@ router.post('/delete', function (request, response) { | ||
| 29 | 29 | console.error('Theme file not found:', filename); |
| 30 | 30 | return response.sendStatus(404); |
| 31 | 31 | } |
| 32 | 32 | fs.rmSyncunlinkSync(filename); |
| 33 | 33 | return response.sendStatus(200); |
| 34 | 34 | } catch (error) { |
| 35 | 35 | console.error(error); |
| @@ -75,7 +75,7 @@ export function invalidateThumbnail(directories, type, file) { | ||
| 75 | 75 | const pathToThumbnail = path.join(folder, file); |
| 76 | 76 | |
| 77 | 77 | if (fs.existsSync(pathToThumbnail)) { |
| 78 | 78 | fs.rmSyncunlinkSync(pathToThumbnail); |
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | |
| @@ -57,7 +57,7 @@ router.post('/delete', (request, response) => { | ||
| 57 | 57 | throw new Error(`World info file ${filename} doesn't exist.`); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | fs.rmSyncunlinkSync(pathToWorldInfo); |
| 61 | 61 | |
| 62 | 62 | return response.sendStatus(200); |
| 63 | 63 | }); |