Skip to content

Commit 9b368ee

Browse files
committed
fix(cli): preserve existing directories during single-file upload
Inspect remote destination types before choosing archive entry names. Keep directory and source symlinks intact, recheck detected type changes, and report the resulting path. Add real tar and live conformance coverage. Closes #4175 Signed-off-by: Shiju <shiju@nvidia.com>
1 parent 834b79a commit 9b368ee

5 files changed

Lines changed: 595 additions & 63 deletions

File tree

‎crates/openshell-cli/src/main.rs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1781,7 +1781,11 @@ enum SandboxCommands {
17811781
#[arg(value_hint = ValueHint::AnyPath)]
17821782
local_path: String,
17831783

1784-
/// Destination path in the sandbox (defaults to the container's working directory).
1784+
/// Destination path in the sandbox (defaults to its working directory).
1785+
///
1786+
/// For an unfiltered single-file upload, an existing directory or a
1787+
/// trailing slash places the file inside that directory. A missing
1788+
/// nested path without a trailing slash renames the file.
17851789
dest: Option<String>,
17861790

17871791
/// Disable `.gitignore` filtering (uploads everything).

‎crates/openshell-cli/src/run.rs‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5110,7 +5110,7 @@ async fn sandbox_upload_planned(
51105110
sandbox_path: Option<&str>,
51115111
tls: &TlsOptions,
51125112
workspace: &str,
5113-
) -> Result<()> {
5113+
) -> Result<Option<String>> {
51145114
match plan {
51155115
SandboxUploadPlan::GitAware { base_dir, files } => {
51165116
sandbox_sync_up_files(
@@ -5123,10 +5123,13 @@ async fn sandbox_upload_planned(
51235123
tls,
51245124
workspace,
51255125
)
5126-
.await
5126+
.await?;
5127+
Ok(None)
51275128
}
51285129
SandboxUploadPlan::Regular => {
5129-
sandbox_sync_up(server, name, local_path, sandbox_path, tls, workspace).await
5130+
sandbox_sync_up(server, name, local_path, sandbox_path, tls, workspace)
5131+
.await
5132+
.map(Some)
51305133
}
51315134
}
51325135
}
@@ -5152,7 +5155,7 @@ pub async fn sandbox_upload(
51525155
dest_display
51535156
);
51545157

5155-
sandbox_upload_planned(
5158+
let uploaded_path = sandbox_upload_planned(
51565159
upload_plan,
51575160
server,
51585161
name,
@@ -5163,7 +5166,11 @@ pub async fn sandbox_upload(
51635166
)
51645167
.await?;
51655168

5166-
eprintln!("{} Upload complete", "✓".green().bold());
5169+
if let Some(path) = uploaded_path {
5170+
eprintln!("{} Upload complete: {path}", "✓".green().bold());
5171+
} else {
5172+
eprintln!("{} Upload complete", "✓".green().bold());
5173+
}
51675174
Ok(())
51685175
}
51695176

0 commit comments

Comments
 (0)