diff --git a/src/client/pxar_backup_stream.rs b/src/client/pxar_backup_stream.rs index 484e7989..f7a57ca9 100644 --- a/src/client/pxar_backup_stream.rs +++ b/src/client/pxar_backup_stream.rs @@ -22,13 +22,14 @@ use crate::tools::wrapped_reader_stream::WrappedReaderStream; /// /// Note: The currect implementation is not fully ansync and can block. pub struct PxarBackupStream { - stream: WrappedReaderStream, + stream: Option>, child: Option>, } impl Drop for PxarBackupStream { fn drop(&mut self) { + self.stream = None; self.child.take().unwrap().join().unwrap(); } } @@ -52,7 +53,7 @@ impl PxarBackupStream { let pipe = unsafe { std::fs::File::from_raw_fd(rx) }; let stream = crate::tools::wrapped_reader_stream::WrappedReaderStream::new(pipe); - Ok(Self { stream, child: Some(child) }) + Ok(Self { stream: Some(stream), child: Some(child) }) } pub fn open(dirname: &Path, all_file_systems: bool, verbose: bool) -> Result { @@ -70,6 +71,6 @@ impl Stream for PxarBackupStream { type Error = Error; fn poll(&mut self) -> Poll>, Error> { - self.stream.poll().map_err(Error::from) + self.stream.as_mut().unwrap().poll().map_err(Error::from) } }