MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / probe_sandbox_source_kind

Function probe_sandbox_source_kind

crates/openshell-cli/src/ssh.rs:1100–1119  ·  view source on GitHub ↗

Probe the sandbox-side source path. The path is assumed to have already been validated by `validate_sandbox_source_path`.

(
    session: &SshSessionConfig,
    sandbox_path: &str,
)

Source from the content-addressed store, hash-verified

1098/// Probe the sandbox-side source path. The path is assumed to have already
1099/// been validated by `validate_sandbox_source_path`.
1100async fn probe_sandbox_source_kind(
1101 session: &SshSessionConfig,
1102 sandbox_path: &str,
1103) -> Result<SandboxSourceKind> {
1104 let probe_cmd = format!(
1105 "if [ -d {path} ]; then printf dir; elif [ -e {path} ]; then printf file; else printf missing; fi",
1106 path = shell_escape(sandbox_path),
1107 );
1108 let kind = ssh_run_capture_stdout(session, &probe_cmd).await?;
1109 match kind.as_str() {
1110 "dir" => Ok(SandboxSourceKind::Directory),
1111 "file" => Ok(SandboxSourceKind::File),
1112 "missing" => Err(miette::miette!(
1113 "sandbox source path '{sandbox_path}' does not exist"
1114 )),
1115 other => Err(miette::miette!(
1116 "unexpected probe output for sandbox source path '{sandbox_path}': '{other}'"
1117 )),
1118 }
1119}
1120
1121/// Pull a path from a sandbox to a local destination using tar-over-SSH.
1122///

Callers 1

sandbox_sync_downFunction · 0.85

Calls 2

ssh_run_capture_stdoutFunction · 0.85
as_strMethod · 0.45

Tested by

no test coverage detected