mirror of
https://github.com/openai/codex.git
synced 2026-11-23 23:10:47 +00:00
Migrate ExecutorFileSystem remove to PathUri
This commit is contained in:
@@ -276,9 +276,11 @@ pub(crate) async fn run_direct_request(
|
||||
}))
|
||||
}
|
||||
FsHelperRequest::Remove(params) => {
|
||||
let path =
|
||||
codex_utils_path_uri::PathUri::from_abs_path(¶ms.path).map_err(map_fs_error)?;
|
||||
file_system
|
||||
.remove(
|
||||
¶ms.path,
|
||||
&path,
|
||||
RemoveOptions {
|
||||
recursive: params.recursive.unwrap_or(true),
|
||||
force: params.force.unwrap_or(true),
|
||||
|
||||
@@ -138,7 +138,7 @@ impl ExecutorFileSystem for LocalFileSystem {
|
||||
|
||||
async fn remove(
|
||||
&self,
|
||||
path: &AbsolutePathBuf,
|
||||
path: &PathUri,
|
||||
options: RemoveOptions,
|
||||
sandbox: Option<&FileSystemSandboxContext>,
|
||||
) -> FileSystemResult<()> {
|
||||
@@ -226,7 +226,7 @@ impl ExecutorFileSystem for UnsandboxedFileSystem {
|
||||
|
||||
async fn remove(
|
||||
&self,
|
||||
path: &AbsolutePathBuf,
|
||||
path: &PathUri,
|
||||
options: RemoveOptions,
|
||||
sandbox: Option<&FileSystemSandboxContext>,
|
||||
) -> FileSystemResult<()> {
|
||||
@@ -355,11 +355,12 @@ impl ExecutorFileSystem for DirectFileSystem {
|
||||
|
||||
async fn remove(
|
||||
&self,
|
||||
path: &AbsolutePathBuf,
|
||||
path: &PathUri,
|
||||
options: RemoveOptions,
|
||||
sandbox: Option<&FileSystemSandboxContext>,
|
||||
) -> FileSystemResult<()> {
|
||||
reject_sandbox_context(sandbox)?;
|
||||
let path = path.to_abs_path()?;
|
||||
match tokio::fs::symlink_metadata(path.as_path()).await {
|
||||
Ok(metadata) => {
|
||||
let file_type = metadata.file_type();
|
||||
|
||||
@@ -174,15 +174,16 @@ impl ExecutorFileSystem for RemoteFileSystem {
|
||||
|
||||
async fn remove(
|
||||
&self,
|
||||
path: &AbsolutePathBuf,
|
||||
path: &PathUri,
|
||||
options: RemoveOptions,
|
||||
sandbox: Option<&FileSystemSandboxContext>,
|
||||
) -> FileSystemResult<()> {
|
||||
trace!("remote fs remove");
|
||||
let path = path.to_abs_path()?;
|
||||
let client = self.client.get().await.map_err(map_remote_error)?;
|
||||
client
|
||||
.fs_remove(FsRemoveParams {
|
||||
path: path.clone(),
|
||||
path,
|
||||
recursive: Some(options.recursive),
|
||||
force: Some(options.force),
|
||||
sandbox: remote_sandbox_context(sandbox),
|
||||
|
||||
@@ -196,7 +196,7 @@ impl ExecutorFileSystem for SandboxedFileSystem {
|
||||
|
||||
async fn remove(
|
||||
&self,
|
||||
path: &AbsolutePathBuf,
|
||||
path: &PathUri,
|
||||
remove_options: RemoveOptions,
|
||||
sandbox: Option<&FileSystemSandboxContext>,
|
||||
) -> FileSystemResult<()> {
|
||||
@@ -204,7 +204,7 @@ impl ExecutorFileSystem for SandboxedFileSystem {
|
||||
self.run_sandboxed(
|
||||
sandbox,
|
||||
FsHelperRequest::Remove(FsRemoveParams {
|
||||
path: path.clone(),
|
||||
path: path.to_abs_path()?,
|
||||
recursive: Some(remove_options.recursive),
|
||||
force: Some(remove_options.force),
|
||||
sandbox: None,
|
||||
|
||||
@@ -175,9 +175,10 @@ impl FileSystemHandler {
|
||||
) -> Result<FsRemoveResponse, JSONRPCErrorError> {
|
||||
let recursive = params.recursive.unwrap_or(true);
|
||||
let force = params.force.unwrap_or(true);
|
||||
let path = PathUri::from_abs_path(¶ms.path).map_err(map_fs_error)?;
|
||||
self.file_system
|
||||
.remove(
|
||||
¶ms.path,
|
||||
&path,
|
||||
RemoveOptions { recursive, force },
|
||||
params.sandbox.as_ref(),
|
||||
)
|
||||
|
||||
@@ -311,7 +311,7 @@ async fn file_system_remove_removes_directory(
|
||||
|
||||
file_system
|
||||
.remove(
|
||||
&absolute_path(&directory_path),
|
||||
&PathUri::from_path(&directory_path)?,
|
||||
RemoveOptions {
|
||||
recursive: true,
|
||||
force: true,
|
||||
|
||||
@@ -583,7 +583,7 @@ async fn file_system_remove_removes_symlink_not_target(
|
||||
let sandbox = workspace_write_sandbox(allowed_dir);
|
||||
file_system
|
||||
.remove(
|
||||
&absolute_path(&symlink_path),
|
||||
&PathUri::from_path(&symlink_path)?,
|
||||
RemoveOptions {
|
||||
recursive: false,
|
||||
force: false,
|
||||
@@ -660,7 +660,7 @@ async fn file_system_remove_rejects_symlink_escape(
|
||||
let sandbox = workspace_write_sandbox(allowed_dir);
|
||||
let error = match file_system
|
||||
.remove(
|
||||
&absolute_path(&requested_path),
|
||||
&PathUri::from_path(&requested_path)?,
|
||||
RemoveOptions {
|
||||
recursive: false,
|
||||
force: false,
|
||||
|
||||
Reference in New Issue
Block a user