mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
fix: replace rmSync with unlinkSync to resolve an issue deleting files with non-English characters in their names
This commit is contained in:
@@ -28,7 +28,7 @@ router.post('/delete', getFileNameValidationFunction('avatar'), function (reques
|
||||
const fileName = path.join(request.user.directories.avatars, sanitize(request.body.avatar));
|
||||
|
||||
if (fs.existsSync(fileName)) {
|
||||
fs.rmSync(fileName);
|
||||
fs.unlinkSync(fileName);
|
||||
return response.send({ result: 'ok' });
|
||||
}
|
||||
|
||||
|
@@ -1150,7 +1150,7 @@ router.post('/delete', validateAvatarUrlMiddleware, async function (request, res
|
||||
return response.sendStatus(400);
|
||||
}
|
||||
|
||||
fs.rmSync(avatarPath);
|
||||
fs.unlinkSync(avatarPath);
|
||||
invalidateThumbnail(request.user.directories, 'avatar', request.body.avatar_url);
|
||||
let dir_name = (request.body.avatar_url.replace('.png', ''));
|
||||
|
||||
|
@@ -449,7 +449,7 @@ router.post('/delete', validateAvatarUrlMiddleware, function (request, response)
|
||||
return response.sendStatus(400);
|
||||
}
|
||||
|
||||
fs.rmSync(filePath);
|
||||
fs.unlinkSync(filePath);
|
||||
console.info(`Deleted chat file: ${filePath}`);
|
||||
return response.send('ok');
|
||||
});
|
||||
|
@@ -29,7 +29,7 @@ router.post('/delete', function (request, response) {
|
||||
console.error('Theme file not found:', filename);
|
||||
return response.sendStatus(404);
|
||||
}
|
||||
fs.rmSync(filename);
|
||||
fs.unlinkSync(filename);
|
||||
return response.sendStatus(200);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
@@ -75,7 +75,7 @@ export function invalidateThumbnail(directories, type, file) {
|
||||
const pathToThumbnail = path.join(folder, file);
|
||||
|
||||
if (fs.existsSync(pathToThumbnail)) {
|
||||
fs.rmSync(pathToThumbnail);
|
||||
fs.unlinkSync(pathToThumbnail);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -57,7 +57,7 @@ router.post('/delete', (request, response) => {
|
||||
throw new Error(`World info file ${filename} doesn't exist.`);
|
||||
}
|
||||
|
||||
fs.rmSync(pathToWorldInfo);
|
||||
fs.unlinkSync(pathToWorldInfo);
|
||||
|
||||
return response.sendStatus(200);
|
||||
});
|
||||
|
Reference in New Issue
Block a user