History

Fixed nushell error when creating new folder when uploading wsl-remote-server (#40432)

Closes #40269 Release Notes: - N/A

kingananas20 committed 1 year ago

Commit cd51efa1 parent e85c0601 file · +11 −5Browse files

Unified · Split

crates/remote/src/transport/wsl.rs+11−5
@@ -206,7 +206,7 @@ impl WslRemoteConnection { · 205 unmodified lines
206206 ))
207207 .unwrap(),
208208 );
209− self.upload_file(&remote_server_path, &tmp_path, delegate, cx)
209+ self.upload_file(&remote_server_path, &tmp_path, delegate, &shell, cx)
210210 .await?;
211211 self.extract_and_install(&tmp_path, &dst_path, delegate, cx)
212212 .await?;
@@ -239,7 +239,8 @@ impl WslRemoteConnection { · 26 unmodified lines
239239 );
240240 let tmp_path = RelPath::unix(&tmp_path).unwrap();
241241
242− self.upload_file(&src_path, &tmp_path, delegate, cx).await?;
242+ self.upload_file(&src_path, &tmp_path, delegate, &shell, cx)
243+ .await?;
243244 self.extract_and_install(&tmp_path, &dst_path, delegate, cx)
244245 .await?;
245246
@@ -251,14 +252,19 @@ impl WslRemoteConnection { · 5 unmodified lines
251252 src_path: &Path,
252253 dst_path: &RelPath,
253254 delegate: &Arc<dyn RemoteClientDelegate>,
255+ shell: &ShellKind,
254256 cx: &mut AsyncApp,
255257 ) -> Result<()> {
256258 delegate.set_status(Some("Uploading remote server to WSL"), cx);
257259
258260 if let Some(parent) = dst_path.parent() {
259− self.run_wsl_command("mkdir", &["-p", &parent.display(PathStyle::Posix)])
260− .await
261− .map_err(|e| anyhow!("Failed to create directory when uploading file: {}", e))?;
261+ let parent = parent.display(PathStyle::Posix);
262+ if *shell == ShellKind::Nushell {
263+ self.run_wsl_command("mkdir", &[&parent]).await
264+ } else {
265+ self.run_wsl_command("mkdir", &["-p", &parent]).await
266+ }
267+ .map_err(|e| anyhow!("Failed to create directory when uploading file: {}", e))?;
262268 }
263269
264270 let t0 = Instant::now();