fix: 修复文件组 5 处目录字段与实现键名脱节
- File_CreateFile: 目录字段 folder_path/name,实现读 path → 必报文件路径为空 - File_GetFileInfo / File_WaitFile: 目录字段 file_path,实现读 path → 读不到 - File_CompressFile: 目录字段 file_path,实现读 pathSrc → 压缩源找不到 - File_Move: 目录字段 file_path/target_path/name,实现与 File_File_Move 共用 pathSrc/pathDest → 读不到;补齐别名兼容
This commit is contained in:
parent
a3fbae9d83
commit
19eb53b5d8
@ -59,7 +59,10 @@ register("File_Write", async (_ctx, node, args) => {
|
||||
});
|
||||
|
||||
register(["File_CreateFile"], async (_ctx, node, args) => {
|
||||
const filePath = requirePath(pick(args, ["path", "file", "file_path"]), "文件路径", node.id, node.componentId);
|
||||
// catalog 字段为 folder_path + name(组合成完整路径),兼容旧键 path
|
||||
const base = pick(args, ["folder_path", "path", "file", "file_path"]);
|
||||
const name = pick(args, ["name"]);
|
||||
const filePath = requirePath(name ? path.join(base, name) : base, "文件路径", node.id, node.componentId);
|
||||
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
||||
await fs.writeFile(filePath, "", { flag: "a" });
|
||||
return filePath;
|
||||
@ -80,8 +83,15 @@ register("File_Copy", async (_ctx, node, args) => {
|
||||
});
|
||||
|
||||
register(["File_File_Move", "File_Move"], async (_ctx, node, args) => {
|
||||
const source = requirePath(pick(args, ["pathSrc", "src", "source"]), "源路径", node.id, node.componentId);
|
||||
const target = requirePath(pick(args, ["pathDest", "dest", "target"]), "目标路径", node.id, node.componentId);
|
||||
// File_Move 的 catalog 字段为 file_type + file_path/folder_path + target_path(+name),与 File_File_Move 的 pathSrc/pathDest 兼容
|
||||
const isFolder = String(args.file_type ?? "file") === "folder";
|
||||
const source = requirePath(pick(args, ["pathSrc", isFolder ? "folder_path" : "file_path", "src", "source"]), "源路径", node.id, node.componentId);
|
||||
let target = pick(args, ["pathDest", "dest"]);
|
||||
if (!target) {
|
||||
const destDir = pick(args, ["target_path"]);
|
||||
const newName = truthy(args.rename) ? pick(args, ["name"]) : "";
|
||||
target = requirePath(newName ? path.join(destDir, newName) : destDir, "目的地路径", node.id, node.componentId);
|
||||
}
|
||||
await fs.mkdir(path.dirname(target), { recursive: true });
|
||||
try {
|
||||
await fs.rename(source, target);
|
||||
@ -152,7 +162,8 @@ register(["File_PathSize", "File_PathSizeNew"], async (_ctx, node, args) => {
|
||||
});
|
||||
|
||||
register("File_GetFileInfo", async (_ctx, node, args) => {
|
||||
const target = requirePath(pick(args, ["path", "file"]), "路径", node.id, node.componentId);
|
||||
// catalog 字段为 file_path,兼容 path/file
|
||||
const target = requirePath(pick(args, ["file_path", "path", "file"]), "路径", node.id, node.componentId);
|
||||
const stat = await fs.stat(target);
|
||||
return {
|
||||
path: target,
|
||||
@ -165,7 +176,8 @@ register("File_GetFileInfo", async (_ctx, node, args) => {
|
||||
});
|
||||
|
||||
register("File_WaitFile", async (ctx, node, args) => {
|
||||
const target = requirePath(pick(args, ["path", "file"]), "文件路径", node.id, node.componentId);
|
||||
// catalog 字段为 file_path,兼容 path/file
|
||||
const target = requirePath(pick(args, ["file_path", "path", "file"]), "文件路径", node.id, node.componentId);
|
||||
const timeout = Math.max(1, Number(args.time_out ?? args.timeout ?? 30)) * 1000;
|
||||
const started = Date.now();
|
||||
while (Date.now() - started < timeout) {
|
||||
@ -185,7 +197,8 @@ register("File_WaitFile", async (ctx, node, args) => {
|
||||
});
|
||||
|
||||
register("File_CompressFile", async (_ctx, node, args) => {
|
||||
const source = requirePath(pick(args, ["pathSrc", "path", "folder_path"]), "源路径", node.id, node.componentId);
|
||||
// catalog 字段为 file_path(文件模式)/folder_path(文件夹模式)+ out_path,兼容旧键
|
||||
const source = requirePath(pick(args, ["file_path", "pathSrc", "path", "folder_path"]), "源路径", node.id, node.componentId);
|
||||
const target = requirePath(pick(args, ["pathDest", "zip_path", "out_path"]), "压缩包路径", node.id, node.componentId);
|
||||
const zip = new AdmZip();
|
||||
const stat = await fs.stat(source);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user