mirror of
https://github.com/openai/codex.git
synced 2026-11-26 23:40:43 +00:00
Fall back when remote filesystem walk is unavailable
This commit is contained in:
@@ -29,6 +29,7 @@ use crate::protocol::FsWalkParams;
|
||||
use crate::protocol::FsWriteFileParams;
|
||||
|
||||
const INVALID_REQUEST_ERROR_CODE: i64 = -32600;
|
||||
const METHOD_NOT_FOUND_ERROR_CODE: i64 = -32601;
|
||||
const NOT_FOUND_ERROR_CODE: i64 = -32004;
|
||||
|
||||
#[path = "remote_file_stream.rs"]
|
||||
@@ -194,14 +195,26 @@ impl RemoteFileSystem {
|
||||
) -> FileSystemResult<WalkOutcome> {
|
||||
trace!("remote fs walk");
|
||||
let client = self.client.get().await.map_err(map_remote_error)?;
|
||||
let response = client
|
||||
let response = match client
|
||||
.fs_walk(FsWalkParams {
|
||||
path: path.clone(),
|
||||
options,
|
||||
sandbox: remote_sandbox_context(sandbox),
|
||||
})
|
||||
.await
|
||||
.map_err(map_remote_error)?;
|
||||
{
|
||||
Ok(response) => response,
|
||||
Err(ExecServerError::Server {
|
||||
code: METHOD_NOT_FOUND_ERROR_CODE,
|
||||
..
|
||||
}) => {
|
||||
return <Self as ExecutorFileSystem>::walk_via_directory_reads(
|
||||
self, path, options, sandbox,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
Err(error) => return Err(map_remote_error(error)),
|
||||
};
|
||||
Ok(response)
|
||||
}
|
||||
|
||||
|
||||
@@ -316,7 +316,19 @@ pub trait ExecutorFileSystem: Send + Sync {
|
||||
options: WalkOptions,
|
||||
sandbox: Option<&'a FileSystemSandboxContext>,
|
||||
) -> ExecutorFileSystemFuture<'a, WalkOutcome> {
|
||||
Box::pin(walk(self, path, options, sandbox))
|
||||
self.walk_via_directory_reads(path, options, sandbox)
|
||||
}
|
||||
|
||||
/// Performs a bounded walk using the primitive filesystem operations.
|
||||
///
|
||||
/// Implementations with an optimized walk transport can use this as a compatibility fallback.
|
||||
fn walk_via_directory_reads<'a>(
|
||||
&'a self,
|
||||
path: &'a PathUri,
|
||||
options: WalkOptions,
|
||||
sandbox: Option<&'a FileSystemSandboxContext>,
|
||||
) -> ExecutorFileSystemFuture<'a, WalkOutcome> {
|
||||
Box::pin(walk_via_directory_reads(self, path, options, sandbox))
|
||||
}
|
||||
|
||||
fn remove<'a>(
|
||||
@@ -335,7 +347,7 @@ pub trait ExecutorFileSystem: Send + Sync {
|
||||
) -> ExecutorFileSystemFuture<'a, ()>;
|
||||
}
|
||||
|
||||
async fn walk<F: ExecutorFileSystem + ?Sized>(
|
||||
async fn walk_via_directory_reads<F: ExecutorFileSystem + ?Sized>(
|
||||
file_system: &F,
|
||||
root: &PathUri,
|
||||
options: WalkOptions,
|
||||
|
||||
Reference in New Issue
Block a user