Fix trailing slashes in path for settings
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import path from 'path';
|
||||
import prisma from '@/server/prisma';
|
||||
import { defaultDatasetsFolder, defaultDataRoot } from '@/paths';
|
||||
import { defaultTrainFolder } from '@/paths';
|
||||
@@ -24,6 +25,9 @@ export const getDatasetsRoot = async () => {
|
||||
if (row?.value && row.value !== '') {
|
||||
datasetsPath = row.value;
|
||||
}
|
||||
// Strip trailing slashes; the routes' `root + path.sep` prefix checks 403
|
||||
// on every file if the stored path ends with a separator.
|
||||
datasetsPath = path.resolve(datasetsPath);
|
||||
myCache.set(key, datasetsPath);
|
||||
return datasetsPath as string;
|
||||
};
|
||||
@@ -43,6 +47,7 @@ export const getTrainingFolder = async () => {
|
||||
if (row?.value && row.value !== '') {
|
||||
trainingRoot = row.value;
|
||||
}
|
||||
trainingRoot = path.resolve(trainingRoot);
|
||||
myCache.set(key, trainingRoot);
|
||||
return trainingRoot as string;
|
||||
};
|
||||
@@ -81,6 +86,7 @@ export const getDataRoot = async () => {
|
||||
if (row?.value && row.value !== '') {
|
||||
dataRoot = row.value;
|
||||
}
|
||||
dataRoot = path.resolve(dataRoot);
|
||||
myCache.set(key, dataRoot);
|
||||
return dataRoot;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user