Skip to content

Commit d9160b9

Browse files
committed
add copy file api
1 parent dcc77e7 commit d9160b9

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

src/PintClient/index.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,38 @@ export class PintFsClient implements IAgentClientFS {
623623
recursive?: boolean,
624624
overwrite?: boolean
625625
): Promise<PickRawFsResult<"fs/copy">> {
626-
throw new Error("Not implemented");
626+
try {
627+
const response = await performFileAction({
628+
client: this.apiClient,
629+
path: {
630+
path: from,
631+
},
632+
body: {
633+
action: 'copy',
634+
destination: to,
635+
},
636+
});
637+
638+
if (response.data) {
639+
// FSCopyResult is an empty object (Record<string, never>)
640+
return {
641+
type: "ok",
642+
result: {},
643+
};
644+
} else {
645+
return {
646+
type: "error",
647+
error: response.error?.message || "Failed to copy file",
648+
errno: null,
649+
};
650+
}
651+
} catch (error) {
652+
return {
653+
type: "error",
654+
error: error instanceof Error ? error.message : "Unknown error",
655+
errno: null,
656+
};
657+
}
627658
}
628659

629660
async rename(

0 commit comments

Comments
 (0)