mirror of
https://github.com/Mintplex-Labs/anything-llm.git
synced 2024-11-10 17:00:11 +01:00
undo path norm whitespace fix
This commit is contained in:
parent
c7e9240801
commit
05488c81e0
@ -49,9 +49,9 @@ function writeToServerDocuments(
|
|||||||
const destination = destinationOverride
|
const destination = destinationOverride
|
||||||
? path.resolve(destinationOverride)
|
? path.resolve(destinationOverride)
|
||||||
: path.resolve(
|
: path.resolve(
|
||||||
__dirname,
|
__dirname,
|
||||||
"../../../server/storage/documents/custom-documents"
|
"../../../server/storage/documents/custom-documents"
|
||||||
);
|
);
|
||||||
if (!fs.existsSync(destination))
|
if (!fs.existsSync(destination))
|
||||||
fs.mkdirSync(destination, { recursive: true });
|
fs.mkdirSync(destination, { recursive: true });
|
||||||
const destinationFilePath = path.resolve(destination, filename) + ".json";
|
const destinationFilePath = path.resolve(destination, filename) + ".json";
|
||||||
@ -82,7 +82,7 @@ async function wipeCollectorStorage() {
|
|||||||
if (file === "__HOTDIR__.md") continue;
|
if (file === "__HOTDIR__.md") continue;
|
||||||
try {
|
try {
|
||||||
fs.rmSync(path.join(directory, file));
|
fs.rmSync(path.join(directory, file));
|
||||||
} catch {}
|
} catch { }
|
||||||
}
|
}
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
@ -97,7 +97,7 @@ async function wipeCollectorStorage() {
|
|||||||
if (file === ".placeholder") continue;
|
if (file === ".placeholder") continue;
|
||||||
try {
|
try {
|
||||||
fs.rmSync(path.join(directory, file));
|
fs.rmSync(path.join(directory, file));
|
||||||
} catch {}
|
} catch { }
|
||||||
}
|
}
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
@ -122,7 +122,7 @@ function isWithin(outer, inner) {
|
|||||||
|
|
||||||
function normalizePath(filepath = "") {
|
function normalizePath(filepath = "") {
|
||||||
const result = path
|
const result = path
|
||||||
.normalize(filepath.replace(/\s/g, "-").trim())
|
.normalize(filepath.trim())
|
||||||
.replace(/^(\.\.(\/|\\|$))+/, "")
|
.replace(/^(\.\.(\/|\\|$))+/, "")
|
||||||
.trim();
|
.trim();
|
||||||
if (["..", ".", "/"].includes(result)) throw new Error("Invalid path.");
|
if (["..", ".", "/"].includes(result)) throw new Error("Invalid path.");
|
||||||
|
Loading…
Reference in New Issue
Block a user