Skip to content

Commit

Permalink
Use cat instead of dd for transferring files (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
rukai authored Nov 10, 2023
1 parent ed25646 commit 5b22da5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions aws-throwaway/examples/aws-throwaway-test-large-file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ async fn main() {
.await;
println!("Time to push 100MB file {:?}", start.elapsed());

let remote_size: usize = instance
.ssh()
.shell("wc -c some_remote_file")
.await
.stdout
.split_ascii_whitespace()
.next()
.unwrap()
.parse()
.unwrap();
assert_eq!(remote_size, FILE_LEN);

let start = Instant::now();
instance
.ssh()
Expand Down
4 changes: 2 additions & 2 deletions aws-throwaway/src/ssh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl SshConnection {

async fn push_file_impl<R: AsyncReadExt + Unpin>(&self, task: &str, source: R, dest: &Path) {
let mut channel = self.session.channel_open_session().await.unwrap();
let command = format!("dd of='{0}'\nchmod 777 {0}", dest.to_str().unwrap());
let command = format!("cat > '{0}'\nchmod 777 {0}", dest.to_str().unwrap());
channel.exec(true, command).await.unwrap();

let mut stdout = vec![];
Expand Down Expand Up @@ -260,7 +260,7 @@ impl SshConnection {
tracing::info!("{task}");

let mut channel = self.session.channel_open_session().await.unwrap();
let command = format!("dd if='{0}'\nchmod 777 {0}", source.to_str().unwrap());
let command = format!("cat '{}'", source.to_str().unwrap());
channel.exec(true, command).await.unwrap();

let mut out = File::create(dest).await.unwrap();
Expand Down

0 comments on commit 5b22da5

Please sign in to comment.