mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-03-03 03:17:54 +01:00
Fix 500 error on fetching an empty folder
This commit is contained in:
parent
189895bd01
commit
cf796af950
@ -2680,8 +2680,12 @@ app.post('/uploadimage', jsonParser, async (request, response) => {
|
||||
});
|
||||
|
||||
app.get('/listimgfiles/:folder', (req, res) => {
|
||||
const directoryPath = path.join(__dirname, 'public/user/images/', req.params.folder);
|
||||
console.log(directoryPath);
|
||||
const directoryPath = path.join(process.cwd(), 'public/user/images/', req.params.folder);
|
||||
|
||||
if (!fs.existsSync(directoryPath)) {
|
||||
fs.mkdirSync(directoryPath, { recursive: true });
|
||||
}
|
||||
|
||||
fs.readdir(directoryPath, (err, files) => {
|
||||
if (err) {
|
||||
return res.status(500).send({ error: "Unable to retrieve files" });
|
||||
|
Loading…
x
Reference in New Issue
Block a user