Skip to content

Commit

Permalink
fix: import failing on large tables
Browse files Browse the repository at this point in the history
Channel close method closes the client channel and does
not wait for the remote process to exit. This was causing
download of incomplete dump file, causing the import to fail.
  • Loading branch information
JoyceBabu committed Nov 26, 2024
1 parent c88cbc3 commit 2ac5b19
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,14 @@ fn main() -> Result<(), Box<dyn Error>> {
let mut channel = sess.channel_session().ok().unwrap();
let exit_status = channel
.exec(&arg)
.and_then(|_| channel.close())
.and_then(|_| {
let mut stdout = String::new();
let mut stderr = String::new();
channel.read_to_string(&mut stdout).unwrap();
channel.stderr().read_to_string(&mut stderr).unwrap();

channel.wait_close()
})
.and_then(|_| channel.exit_status());

match exit_status {
Expand Down Expand Up @@ -337,8 +344,6 @@ fn main() -> Result<(), Box<dyn Error>> {
_ => warn!("Failed to delete temporary file from remote filesystem."),
}

// TODO: Delete temporary file from remote filesystem

let f = BufReader::new(File::open(&path).unwrap());

Check warning on line 347 in src/main.rs

View workflow job for this annotation

GitHub Actions / clippy

the borrowed expression implements the required traits

warning: the borrowed expression implements the required traits --> src/main.rs:347:39 | 347 | let f = BufReader::new(File::open(&path).unwrap()); | ^^^^^ help: change this to: `path` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrows_for_generic_args = note: `#[warn(clippy::needless_borrows_for_generic_args)]` on by default

let v = vec!["-u", &db_user, &pass_arg, &db_name];
Expand Down

0 comments on commit 2ac5b19

Please sign in to comment.