Skip to content

Commit 9d93f91

Browse files
committed
add rename file implementation
1 parent a5fafee commit 9d93f91

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
@@ -595,7 +595,38 @@ export class PintFsClient implements IAgentClientFS {
595595
to: string,
596596
overwrite?: boolean
597597
): Promise<PickRawFsResult<"fs/rename">> {
598-
throw new Error("Not implemented");
598+
try {
599+
const response = await performFileAction({
600+
client: this.apiClient,
601+
path: {
602+
path: from,
603+
},
604+
body: {
605+
action: 'move',
606+
destination: to,
607+
},
608+
});
609+
610+
if (response.data) {
611+
// FSRenameResult is an empty object (Record<string, never>)
612+
return {
613+
type: "ok",
614+
result: {},
615+
};
616+
} else {
617+
return {
618+
type: "error",
619+
error: response.error?.message || "Failed to rename/move file",
620+
errno: null,
621+
};
622+
}
623+
} catch (error) {
624+
return {
625+
type: "error",
626+
error: error instanceof Error ? error.message : "Unknown error",
627+
errno: null,
628+
};
629+
}
599630
}
600631

601632
async watch(

0 commit comments

Comments
 (0)