refactor: refactor diff mode to correctly fork and handle decompressed data
This commit is contained in:
27
src/main.rs
27
src/main.rs
@@ -524,9 +524,7 @@ fn mode_diff(cmd: &mut Command, args: Args, ids: &mut Vec<i64>, tags: &mut Vec<S
|
|||||||
|
|
||||||
let mut child = std::process::Command::new("diff")
|
let mut child = std::process::Command::new("diff")
|
||||||
.arg("-u")
|
.arg("-u")
|
||||||
.arg(format!("/dev/fd/{}", fd_a_read))
|
.stdin(std::process::Stdio::piped())
|
||||||
.arg(format!("/dev/fd/{}", fd_b_read))
|
|
||||||
.stdin(std::process::Stdio::null())
|
|
||||||
.stdout(std::process::Stdio::piped())
|
.stdout(std::process::Stdio::piped())
|
||||||
.stderr(std::process::Stdio::piped())
|
.stderr(std::process::Stdio::piped())
|
||||||
.spawn()
|
.spawn()
|
||||||
@@ -534,14 +532,37 @@ fn mode_diff(cmd: &mut Command, args: Args, ids: &mut Vec<i64>, tags: &mut Vec<S
|
|||||||
|
|
||||||
let stdout_a = unsafe { std::fs::File::from_raw_fd(fd_a_write) };
|
let stdout_a = unsafe { std::fs::File::from_raw_fd(fd_a_write) };
|
||||||
let stdout_b = unsafe { std::fs::File::from_raw_fd(fd_b_write) };
|
let stdout_b = unsafe { std::fs::File::from_raw_fd(fd_b_write) };
|
||||||
|
let stdout_a = BufWriter::new(stdout_a);
|
||||||
|
let stdout_b = BufWriter::new(stdout_b);
|
||||||
|
let stdout_a = BufWriter::new(stdout_a);
|
||||||
|
let stdout_b = BufWriter::new(stdout_b);
|
||||||
|
|
||||||
let mut stdout_a = unsafe { std::fs::File::from_raw_fd(fd_a_write) };
|
let mut stdout_a = unsafe { std::fs::File::from_raw_fd(fd_a_write) };
|
||||||
let mut stdout_b = unsafe { std::fs::File::from_raw_fd(fd_b_write) };
|
let mut stdout_b = unsafe { std::fs::File::from_raw_fd(fd_b_write) };
|
||||||
|
|
||||||
compression_engine_a.copy(item_path_a.clone(), &mut stdout_a)?;
|
compression_engine_a.copy(item_path_a.clone(), &mut stdout_a)?;
|
||||||
compression_engine_b.copy(item_path_b.clone(), &mut stdout_b)?;
|
compression_engine_b.copy(item_path_b.clone(), &mut stdout_b)?;
|
||||||
|
let stdout_a = BufWriter::new(stdout_a);
|
||||||
|
let stdout_b = BufWriter::new(stdout_b);
|
||||||
|
let stdout_a = BufWriter::new(stdout_a);
|
||||||
|
let stdout_b = BufWriter::new(stdout_b);
|
||||||
|
|
||||||
let output = child.wait_with_output().expect("Failed to wait on diff command");
|
let output = child.wait_with_output().expect("Failed to wait on diff command");
|
||||||
|
if output.status.success() {
|
||||||
|
println!("{}", String::from_utf8_lossy(&output.stdout));
|
||||||
|
} else {
|
||||||
|
eprintln!("{}", String::from_utf8_lossy(&output.stderr));
|
||||||
|
}
|
||||||
|
if output.status.success() {
|
||||||
|
println!("{}", String::from_utf8_lossy(&output.stdout));
|
||||||
|
} else {
|
||||||
|
eprintln!("{}", String::from_utf8_lossy(&output.stderr));
|
||||||
|
}
|
||||||
|
if output.status.success() {
|
||||||
|
println!("{}", String::from_utf8_lossy(&output.stdout));
|
||||||
|
} else {
|
||||||
|
eprintln!("{}", String::from_utf8_lossy(&output.stderr));
|
||||||
|
}
|
||||||
|
|
||||||
if output.status.success() {
|
if output.status.success() {
|
||||||
println!("{}", String::from_utf8_lossy(&output.stdout));
|
println!("{}", String::from_utf8_lossy(&output.stdout));
|
||||||
|
|||||||
Reference in New Issue
Block a user