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
206 ))206 ))
207 .unwrap(),207 .unwrap(),
208 );208 );
209 self.upload_file(&remote_server_path, &tmp_path, delegate, cx)209 self.upload_file(&remote_server_path, &tmp_path, delegate, &shell, cx)
210 .await?;210 .await?;
211 self.extract_and_install(&tmp_path, &dst_path, delegate, cx)211 self.extract_and_install(&tmp_path, &dst_path, delegate, cx)
212 .await?;212 .await?;
@@ -239,7 +239,8 @@ impl WslRemoteConnection { · 26 unmodified lines
239 );239 );
240 let tmp_path = RelPath::unix(&tmp_path).unwrap();240 let tmp_path = RelPath::unix(&tmp_path).unwrap();
241 241
242 self.upload_file(&src_path, &tmp_path, delegate, cx).await?;242 self.upload_file(&src_path, &tmp_path, delegate, &shell, cx)
243 .await?;
243 self.extract_and_install(&tmp_path, &dst_path, delegate, cx)244 self.extract_and_install(&tmp_path, &dst_path, delegate, cx)
244 .await?;245 .await?;
245 246
@@ -251,14 +252,19 @@ impl WslRemoteConnection { · 5 unmodified lines
251 src_path: &Path,252 src_path: &Path,
252 dst_path: &RelPath,253 dst_path: &RelPath,
253 delegate: &Arc<dyn RemoteClientDelegate>,254 delegate: &Arc<dyn RemoteClientDelegate>,
255 shell: &ShellKind,
254 cx: &mut AsyncApp,256 cx: &mut AsyncApp,
255 ) -> Result<()> {257 ) -> Result<()> {
256 delegate.set_status(Some("Uploading remote server to WSL"), cx);258 delegate.set_status(Some("Uploading remote server to WSL"), cx);
257 259
258 if let Some(parent) = dst_path.parent() {260 if let Some(parent) = dst_path.parent() {
259 self.run_wsl_command("mkdir", &["-p", &parent.display(PathStyle::Posix)])261 let parent = parent.display(PathStyle::Posix);
260 .await262 if *shell == ShellKind::Nushell {
261 .map_err(|e| anyhow!("Failed to create directory when uploading file: {}", e))?;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))?;
262 }268 }
263 269
264 let t0 = Instant::now();270 let t0 = Instant::now();