Skip to content

Commit 8aa5846

Browse files
authored
fix(cli): preserve existing directories during single-file upload (#4177)
* 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> * fix(cli): box upload future in sandbox_create Boxing the upload future keeps the sandbox_create future under the clippy::large_futures threshold after sandbox_upload_planned began returning the uploaded path. Signed-off-by: Shiju <shiju@nvidia.com> --------- Signed-off-by: Shiju <shiju@nvidia.com>
1 parent 1fff8b9 commit 8aa5846

5 files changed

Lines changed: 599 additions & 65 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: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,15 +1060,17 @@ pub async fn sandbox_create(
10601060
"\u{2022}".dimmed(),
10611061
);
10621062
}
1063-
sandbox_upload_planned(
1063+
// Boxed so the upload state machine lives on the heap instead of
1064+
// inflating the `sandbox_create` future (clippy::large_futures).
1065+
Box::pin(sandbox_upload_planned(
10641066
upload_plan,
10651067
&effective_server,
10661068
&sandbox_name,
10671069
Path::new(local_path),
10681070
dest,
10691071
&effective_tls,
10701072
workspace,
1071-
)
1073+
))
10721074
.await
10731075
.wrap_err_with(|| {
10741076
format!(
@@ -5110,7 +5112,7 @@ async fn sandbox_upload_planned(
51105112
sandbox_path: Option<&str>,
51115113
tls: &TlsOptions,
51125114
workspace: &str,
5113-
) -> Result<()> {
5115+
) -> Result<Option<String>> {
51145116
match plan {
51155117
SandboxUploadPlan::GitAware { base_dir, files } => {
51165118
sandbox_sync_up_files(
@@ -5123,10 +5125,13 @@ async fn sandbox_upload_planned(
51235125
tls,
51245126
workspace,
51255127
)
5126-
.await
5128+
.await?;
5129+
Ok(None)
51275130
}
51285131
SandboxUploadPlan::Regular => {
5129-
sandbox_sync_up(server, name, local_path, sandbox_path, tls, workspace).await
5132+
sandbox_sync_up(server, name, local_path, sandbox_path, tls, workspace)
5133+
.await
5134+
.map(Some)
51305135
}
51315136
}
51325137
}
@@ -5152,7 +5157,7 @@ pub async fn sandbox_upload(
51525157
dest_display
51535158
);
51545159

5155-
sandbox_upload_planned(
5160+
let uploaded_path = sandbox_upload_planned(
51565161
upload_plan,
51575162
server,
51585163
name,
@@ -5163,7 +5168,11 @@ pub async fn sandbox_upload(
51635168
)
51645169
.await?;
51655170

5166-
eprintln!("{} Upload complete", "✓".green().bold());
5171+
if let Some(path) = uploaded_path {
5172+
eprintln!("{} Upload complete: {path}", "✓".green().bold());
5173+
} else {
5174+
eprintln!("{} Upload complete", "✓".green().bold());
5175+
}
51675176
Ok(())
51685177
}
51695178

0 commit comments

Comments
 (0)