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

Function sandbox_sync_down_file

crates/openshell-cli/src/ssh.rs:1219–1254  ·  view source on GitHub ↗
(
    session: &SshSessionConfig,
    sandbox_path: &str,
    dest: &str,
)

Source from the content-addressed store, hash-verified

1217}
1218
1219async fn sandbox_sync_down_file(
1220 session: &SshSessionConfig,
1221 sandbox_path: &str,
1222 dest: &str,
1223) -> Result<()> {
1224 let (parent, basename) = split_sandbox_path(sandbox_path);
1225 let dest_exists_as_dir = fs::symlink_metadata(Path::new(dest)).is_ok_and(|m| m.is_dir());
1226 let final_path = resolve_file_download_target(dest, basename, dest_exists_as_dir);
1227
1228 let staging_parent = final_path
1229 .parent()
1230 .ok_or_else(|| miette::miette!("destination '{}' has no parent directory", dest))?;
1231 fs::create_dir_all(staging_parent)
1232 .into_diagnostic()
1233 .wrap_err_with(|| {
1234 format!(
1235 "failed to create local destination directory '{}'",
1236 staging_parent.display()
1237 )
1238 })?;
1239
1240 let staging = tempfile::TempDir::new_in(staging_parent)
1241 .into_diagnostic()
1242 .wrap_err("failed to create download staging directory")?;
1243
1244 let tar_cmd = build_single_file_tar_cmd(parent, basename);
1245 stream_sandbox_tar(session, tar_cmd, staging.path()).await?;
1246
1247 place_downloaded_file(staging.path(), basename, &final_path).wrap_err_with(|| {
1248 format!(
1249 "failed to place downloaded file at '{}'",
1250 final_path.display()
1251 )
1252 })?;
1253 Ok(())
1254}
1255
1256/// Move a single file extracted by `stream_sandbox_tar` into its final
1257/// position on the host.

Callers 1

sandbox_sync_downFunction · 0.85

Calls 6

split_sandbox_pathFunction · 0.85
stream_sandbox_tarFunction · 0.85
place_downloaded_fileFunction · 0.85
pathMethod · 0.80

Tested by

no test coverage detected