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

Function resolve_file_download_target

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

Resolve the host-side target path for a downloaded *file*, following `cp`-style semantics. - If `dest_str` ends with `/` or already exists as a directory, the file is placed inside it as ` / `. - Otherwise `dest_str` is treated as the exact file path to write. `dest_exists_as_dir` is taken as a parameter (rather than queried inside) so this function stays pure and unit-testa

(
    dest_str: &str,
    source_basename: &str,
    dest_exists_as_dir: bool,
)

Source from the content-addressed store, hash-verified

922/// so this function stays pure and unit-testable; the caller performs the
923/// filesystem check.
924fn resolve_file_download_target(
925 dest_str: &str,
926 source_basename: &str,
927 dest_exists_as_dir: bool,
928) -> PathBuf {
929 let trailing_slash = dest_str.ends_with('/');
930 let dest_path = Path::new(dest_str);
931 if trailing_slash || dest_exists_as_dir {
932 dest_path.join(source_basename)
933 } else {
934 dest_path.to_path_buf()
935 }
936}
937
938/// Push a list of files from a local directory into a sandbox using tar-over-SSH.
939///

Calls

no outgoing calls