Migrate ExecutorFileSystem write_file to PathUri

This commit is contained in:
Codex
2026-06-10 22:15:02 +00:00
committed by Adam Perry
parent df0f70f7b3
commit 3f075fccbb
19 changed files with 94 additions and 53 deletions
+3 -1
View File
@@ -200,13 +200,15 @@ pub(crate) async fn run_direct_request(
}))
}
FsHelperRequest::WriteFile(params) => {
let path =
codex_utils_path_uri::PathUri::from_abs_path(&params.path).map_err(map_fs_error)?;
let bytes = STANDARD.decode(params.data_base64).map_err(|err| {
invalid_request(format!(
"{FS_WRITE_FILE_METHOD} requires valid base64 dataBase64: {err}"
))
})?;
file_system
.write_file(&params.path, bytes, /*sandbox*/ None)
.write_file(&path, bytes, /*sandbox*/ None)
.await
.map_err(map_fs_error)?;
Ok(FsHelperPayload::WriteFile(FsWriteFileResponse {}))
@@ -100,7 +100,7 @@ impl ExecutorFileSystem for LocalFileSystem {
async fn write_file(
&self,
path: &AbsolutePathBuf,
path: &PathUri,
contents: Vec<u8>,
sandbox: Option<&FileSystemSandboxContext>,
) -> FileSystemResult<()> {
@@ -182,7 +182,7 @@ impl ExecutorFileSystem for UnsandboxedFileSystem {
async fn write_file(
&self,
path: &AbsolutePathBuf,
path: &PathUri,
contents: Vec<u8>,
sandbox: Option<&FileSystemSandboxContext>,
) -> FileSystemResult<()> {
@@ -288,11 +288,12 @@ impl ExecutorFileSystem for DirectFileSystem {
async fn write_file(
&self,
path: &AbsolutePathBuf,
path: &PathUri,
contents: Vec<u8>,
sandbox: Option<&FileSystemSandboxContext>,
) -> FileSystemResult<()> {
reject_sandbox_context(sandbox)?;
let path = path.to_abs_path()?;
tokio::fs::write(path.as_path(), contents).await
}
@@ -84,15 +84,16 @@ impl ExecutorFileSystem for RemoteFileSystem {
async fn write_file(
&self,
path: &AbsolutePathBuf,
path: &PathUri,
contents: Vec<u8>,
sandbox: Option<&FileSystemSandboxContext>,
) -> FileSystemResult<()> {
trace!("remote fs write_file");
let path = path.to_abs_path()?;
let client = self.client.get().await.map_err(map_remote_error)?;
client
.fs_write_file(FsWriteFileParams {
path: path.clone(),
path,
data_base64: STANDARD.encode(contents),
sandbox: remote_sandbox_context(sandbox),
})
@@ -100,7 +100,7 @@ impl ExecutorFileSystem for SandboxedFileSystem {
async fn write_file(
&self,
path: &AbsolutePathBuf,
path: &PathUri,
contents: Vec<u8>,
sandbox: Option<&FileSystemSandboxContext>,
) -> FileSystemResult<()> {
@@ -108,7 +108,7 @@ impl ExecutorFileSystem for SandboxedFileSystem {
self.run_sandboxed(
sandbox,
FsHelperRequest::WriteFile(FsWriteFileParams {
path: path.clone(),
path: path.to_abs_path()?,
data_base64: STANDARD.encode(contents),
sandbox: None,
}),
@@ -68,13 +68,14 @@ impl FileSystemHandler {
&self,
params: FsWriteFileParams,
) -> Result<FsWriteFileResponse, JSONRPCErrorError> {
let path = PathUri::from_abs_path(&params.path).map_err(map_fs_error)?;
let bytes = STANDARD.decode(params.data_base64).map_err(|err| {
invalid_request(format!(
"{FS_WRITE_FILE_METHOD} requires valid base64 dataBase64: {err}"
))
})?;
self.file_system
.write_file(&params.path, bytes, params.sandbox.as_ref())
.write_file(&path, bytes, params.sandbox.as_ref())
.await
.map_err(map_fs_error)?;
Ok(FsWriteFileResponse {})