fix: File_DecompressFile misleading "ADM-ZIP: Invalid filename" for missing archive
adm-zip throws "ADM-ZIP: Invalid filename" both for corrupt entries AND when the archive file simply does not exist, which sent us chasing phantom filename issues. Now the handler checks file existence first and reports "压缩包不存在:<path>" with a recommendation pointing out that File_CompressFile appends .zip to the full source name (a.txt -> a.txt.zip) and that the compress node's output variable should be used to chain the real artifact path.
This commit is contained in:
parent
624d13f2ef
commit
0db3e59f75
@ -246,6 +246,10 @@ register("File_CompressFile", async (_ctx, node, args) => {
|
||||
|
||||
register("File_DecompressFile", async (_ctx, node, args) => {
|
||||
const source = requirePath(pick(args, ["folder_path", "path", "zip_path"]), "压缩包路径", node.id, node.componentId);
|
||||
// adm-zip 对不存在的文件抛 "ADM-ZIP: Invalid filename",极具误导性;先显式检查文件存在性
|
||||
await fs.access(source).catch(() => {
|
||||
throw new RuntimeError("file_not_found", `压缩包不存在:${source}`, { nodeId: node.id, componentId: node.componentId, recommendation: "确认压缩包实际产物路径(压缩组件默认在原文件名后追加 .zip,如 a.txt 会压成 a.txt.zip),或用压缩节点的输出变量传入" });
|
||||
});
|
||||
const saveToSourceDir = String(args.direct_type ?? "1") !== "0";
|
||||
const target = saveToSourceDir
|
||||
? path.dirname(source)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user