implementing model selector
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const { Router } = require('express');
|
||||
const settings = require('../config/settings');
|
||||
const fs = require('fs');
|
||||
|
||||
const router = Router();
|
||||
|
||||
@@ -32,6 +33,18 @@ router.patch('/', (req, res) => {
|
||||
updates.scoreThreshold = val;
|
||||
}
|
||||
|
||||
if (req.body.modelsFolderPath !== undefined) {
|
||||
const val = req.body.modelsFolderPath.trim();
|
||||
if (!val) return res.status(400).json({ error: 'modelsFolderPath cannot be empty' });
|
||||
// Verify the path exists and is readable
|
||||
try {
|
||||
fs.readdirSync(val);
|
||||
} catch {
|
||||
return res.status(400).json({ error: `Path not accessible: ${val}` });
|
||||
}
|
||||
updates.modelsFolderPath = val;
|
||||
}
|
||||
|
||||
res.json(settings.save(updates));
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user