Skip to content

Commit

Permalink
fix: toAbsolutePath err for linux
Browse files Browse the repository at this point in the history
  • Loading branch information
yumao233 committed Jan 19, 2025
1 parent c66c880 commit 47c86b2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion daemon/src/routers/http_router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions daemon/src/service/system_file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
Expand All @@ -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));
}
Expand Down

0 comments on commit 47c86b2

Please sign in to comment.