mirror of
https://github.com/MCSManager/MCSManager.git
synced 2025-04-06 17:10:29 +08:00
fix: toAbsolutePath err for linux
This commit is contained in:
parent
c66c880eb3
commit
47c86b2bc5
@ -121,7 +121,7 @@ router.post("/upload/:key", async (ctx) => {
|
||||
|
||||
if (unzip) {
|
||||
const instanceFiles = new FileManager(instance.absoluteCwdPath());
|
||||
instanceFiles.unzip(fileSaveAbsolutePath, path.dirname(fileSaveAbsolutePath), zipCode);
|
||||
instanceFiles.unzip(fileSaveAbsolutePath, ".", zipCode);
|
||||
}
|
||||
ctx.body = "OK";
|
||||
return;
|
||||
|
@ -39,6 +39,9 @@ export default class FileManager {
|
||||
|
||||
toAbsolutePath(fileName: string = "") {
|
||||
const topAbsolutePath = this.topPath;
|
||||
|
||||
if (path.normalize(fileName).indexOf(topAbsolutePath) === 0) return fileName;
|
||||
|
||||
let finalPath = "";
|
||||
if (os.platform() === "win32") {
|
||||
const reg = new RegExp("^[A-Za-z]{1}:[\\\\/]{1}");
|
||||
@ -47,11 +50,8 @@ export default class FileManager {
|
||||
} else if (reg.test(fileName)) {
|
||||
finalPath = path.normalize(fileName);
|
||||
}
|
||||
} else {
|
||||
if (path.isAbsolute(fileName)) {
|
||||
finalPath = path.normalize(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
if (!finalPath) {
|
||||
finalPath = path.normalize(path.join(this.topPath, this.cwd, fileName));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user