fix: file operations acknowledge pwd now
file operations (edit, download, upload) on the client did not work outside of the current working directory of the binary on the server, as they did not acknowledge the current working directory on the client
This commit is contained in:
parent
726e6dff13
commit
fb98d062ef
@ -120,12 +120,19 @@ async fn run_command(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn edit_file(connection: Arc<Connection>, remote_path: PathBuf) -> anyhow::Result<()> {
|
async fn edit_file(
|
||||||
|
cwd: &str,
|
||||||
|
connection: Arc<Connection>,
|
||||||
|
remote_path: PathBuf,
|
||||||
|
) -> anyhow::Result<()> {
|
||||||
let local_path = tempfile::NamedTempFile::new()?.into_temp_path();
|
let local_path = tempfile::NamedTempFile::new()?.into_temp_path();
|
||||||
|
|
||||||
|
let mut remote_path_used = PathBuf::from(cwd);
|
||||||
|
remote_path_used.extend(&remote_path);
|
||||||
|
|
||||||
commands::download::download_file(
|
commands::download::download_file(
|
||||||
Arc::clone(&connection),
|
Arc::clone(&connection),
|
||||||
remote_path.clone(),
|
remote_path_used.clone(),
|
||||||
local_path.to_owned(),
|
local_path.to_owned(),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
@ -144,8 +151,12 @@ async fn edit_file(connection: Arc<Connection>, remote_path: PathBuf) -> anyhow:
|
|||||||
.wait()
|
.wait()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
commands::upload::upload_file(Arc::clone(&connection), local_path.to_owned(), remote_path)
|
commands::upload::upload_file(
|
||||||
.await?;
|
Arc::clone(&connection),
|
||||||
|
local_path.to_owned(),
|
||||||
|
remote_path_used,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -246,9 +257,14 @@ pub(super) async fn shell(
|
|||||||
}),
|
}),
|
||||||
_,
|
_,
|
||||||
) => {
|
) => {
|
||||||
if let Err(e) =
|
let mut remote_path_used = PathBuf::from(&cwd);
|
||||||
commands::upload::upload_file(Arc::clone(&connection), local_file, remote_path)
|
remote_path_used.extend(&remote_path);
|
||||||
.await
|
if let Err(e) = commands::upload::upload_file(
|
||||||
|
Arc::clone(&connection),
|
||||||
|
local_file,
|
||||||
|
remote_path_used,
|
||||||
|
)
|
||||||
|
.await
|
||||||
{
|
{
|
||||||
eprintln!("{e:?}")
|
eprintln!("{e:?}")
|
||||||
}
|
}
|
||||||
@ -260,9 +276,11 @@ pub(super) async fn shell(
|
|||||||
}),
|
}),
|
||||||
_,
|
_,
|
||||||
) => {
|
) => {
|
||||||
|
let mut remote_path_used = PathBuf::from(&cwd);
|
||||||
|
remote_path_used.extend(&remote_file);
|
||||||
if let Err(e) = commands::download::download_file(
|
if let Err(e) = commands::download::download_file(
|
||||||
Arc::clone(&connection),
|
Arc::clone(&connection),
|
||||||
remote_file,
|
remote_path_used,
|
||||||
local_path,
|
local_path,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
@ -272,7 +290,7 @@ pub(super) async fn shell(
|
|||||||
}
|
}
|
||||||
(Ok(SparseCommands::EditFile { remote_path }), _) => {
|
(Ok(SparseCommands::EditFile { remote_path }), _) => {
|
||||||
pause.store(true, Ordering::SeqCst);
|
pause.store(true, Ordering::SeqCst);
|
||||||
if let Err(e) = edit_file(Arc::clone(&connection), remote_path).await {
|
if let Err(e) = edit_file(&cwd, Arc::clone(&connection), remote_path).await {
|
||||||
eprintln!("{e:?}");
|
eprintln!("{e:?}");
|
||||||
}
|
}
|
||||||
pause.store(false, Ordering::Relaxed);
|
pause.store(false, Ordering::Relaxed);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user