From d3fd28461c037ef52b7b2ec7e2239f65b2943015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BC=D1=98=D0=B0=D0=BD=20=D0=93=D0=B5=D0=BE?= =?UTF-8?q?=D1=80=D0=B3=D0=B8=D0=B5=D0=B2=D1=81=D0=BA=D0=B8?= Date: Sun, 20 Sep 2020 19:11:47 +0200 Subject: [PATCH] stream_tar_in_thread will take a Path now it's more common for functions to receive the immutable Path as input argument, as opposed to a PathBuf --- src/threaded_archiver.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/threaded_archiver.rs b/src/threaded_archiver.rs index 88af807..e6a761e 100644 --- a/src/threaded_archiver.rs +++ b/src/threaded_archiver.rs @@ -1,7 +1,7 @@ use futures::prelude::*; use std::io; -use std::path::PathBuf; +use std::path::Path; use std::thread; /* @@ -12,12 +12,13 @@ use std::thread; type Stream = futures::channel::mpsc::Receiver; type Sender = futures::channel::mpsc::Sender; -pub fn stream_tar_in_thread(path: PathBuf) -> Stream { +pub fn stream_tar_in_thread

(path: P) -> Stream + where P: AsRef + Send + 'static { let (writer, stream) = StreamWriter::new(64); thread::spawn(move || { let mut a = tar::Builder::new(writer); - let last_path_component = path.file_name().unwrap(); + let last_path_component = path.as_ref().file_name().unwrap(); a.mode(tar::HeaderMode::Deterministic); a.append_dir_all(last_path_component, &path) .unwrap_or_else(|e| println!("{}", e));