cleanup: remove unnecessary 'mut' and '.clone()'

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2020-12-04 11:53:34 +01:00
parent 19f5aa252f
commit 0bfcea6a11
8 changed files with 8 additions and 11 deletions

View File

@ -305,7 +305,7 @@ async fn backup_directory<P: AsRef<Path>>(
)?; )?;
let mut chunk_stream = ChunkStream::new(pxar_stream, chunk_size); let mut chunk_stream = ChunkStream::new(pxar_stream, chunk_size);
let (mut tx, rx) = mpsc::channel(10); // allow to buffer 10 chunks let (tx, rx) = mpsc::channel(10); // allow to buffer 10 chunks
let stream = ReceiverStream::new(rx) let stream = ReceiverStream::new(rx)
.map_err(Error::from); .map_err(Error::from);

View File

@ -164,7 +164,7 @@ async fn run() -> Result<(), Error> {
} }
fn accept_connections( fn accept_connections(
mut listener: tokio::net::TcpListener, listener: tokio::net::TcpListener,
acceptor: Arc<openssl::ssl::SslAcceptor>, acceptor: Arc<openssl::ssl::SslAcceptor>,
debug: bool, debug: bool,
) -> tokio::sync::mpsc::Receiver<Result<std::pin::Pin<Box<tokio_openssl::SslStream<tokio::net::TcpStream>>>, Error>> { ) -> tokio::sync::mpsc::Receiver<Result<std::pin::Pin<Box<tokio_openssl::SslStream<tokio::net::TcpStream>>>, Error>> {

View File

@ -294,7 +294,7 @@ async fn mount_do(param: Value, pipe: Option<Fd>) -> Result<Value, Error> {
// poll until loop file is mapped (or errors) // poll until loop file is mapped (or errors)
select! { select! {
res = session_fut => { _res = session_fut => {
bail!("FUSE session unexpectedly ended before loop file mapping"); bail!("FUSE session unexpectedly ended before loop file mapping");
}, },
res = st_recv.try_next() => { res = st_recv.try_next() => {

View File

@ -583,6 +583,7 @@ impl BackupWriter {
}) })
.merge_known_chunks() .merge_known_chunks()
.try_for_each(move |merged_chunk_info| { .try_for_each(move |merged_chunk_info| {
let upload_queue = upload_queue.clone();
if let MergedChunkInfo::New(chunk_info) = merged_chunk_info { if let MergedChunkInfo::New(chunk_info) = merged_chunk_info {
let offset = chunk_info.offset; let offset = chunk_info.offset;
@ -610,7 +611,6 @@ impl BackupWriter {
let new_info = MergedChunkInfo::Known(vec![(offset, digest)]); let new_info = MergedChunkInfo::Known(vec![(offset, digest)]);
let mut upload_queue = upload_queue.clone();
future::Either::Left(h2 future::Either::Left(h2
.send_request(request, upload_data) .send_request(request, upload_data)
.and_then(move |response| async move { .and_then(move |response| async move {
@ -621,7 +621,6 @@ impl BackupWriter {
}) })
) )
} else { } else {
let mut upload_queue = upload_queue.clone();
future::Either::Right(async move { future::Either::Right(async move {
upload_queue upload_queue
.send((merged_chunk_info, None)) .send((merged_chunk_info, None))
@ -673,8 +672,6 @@ impl BackupWriter {
break; break;
} }
let mut upload_queue = upload_queue.clone();
if verbose { eprintln!("send test data ({} bytes)", data.len()); } if verbose { eprintln!("send test data ({} bytes)", data.len()); }
let request = H2Client::request_builder("localhost", "POST", "speedtest", None, None).unwrap(); let request = H2Client::request_builder("localhost", "POST", "speedtest", None, None).unwrap();
let request_future = self.h2.send_request(request, Some(bytes::Bytes::from(data.clone()))).await?; let request_future = self.h2.send_request(request, Some(bytes::Bytes::from(data.clone()))).await?;

View File

@ -21,7 +21,7 @@ where
let backup_user = crate::backup::backup_user()?; let backup_user = crate::backup::backup_user()?;
let backup_gid = backup_user.gid.as_raw(); let backup_gid = backup_user.gid.as_raw();
let mut socket = UnixListener::bind(&path)?; let socket = UnixListener::bind(&path)?;
let func = Arc::new(func); let func = Arc::new(func);

View File

@ -58,7 +58,7 @@ impl AsyncChannelWriter {
} }
} }
let mut sender = match self.sender.take() { let sender = match self.sender.take() {
Some(sender) => sender, Some(sender) => sender,
None => return Poll::Ready(Err(io_err_other("no sender"))), None => return Poll::Ready(Err(io_err_other("no sender"))),
}; };

View File

@ -159,7 +159,7 @@ fn test_broadcast_future() {
.map_err(|err| { panic!("got error {}", err); }) .map_err(|err| { panic!("got error {}", err); })
.map(|_| ()); .map(|_| ());
let mut rt = tokio::runtime::Runtime::new().unwrap(); let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(async move { rt.block_on(async move {
let r1 = tokio::spawn(receiver1); let r1 = tokio::spawn(receiver1);
let r2 = tokio::spawn(receiver2); let r2 = tokio::spawn(receiver2);

View File

@ -39,7 +39,7 @@ fn worker_task_abort() -> Result<(), Error> {
let errmsg: Arc<Mutex<Option<String>>> = Arc::new(Mutex::new(None)); let errmsg: Arc<Mutex<Option<String>>> = Arc::new(Mutex::new(None));
let errmsg1 = errmsg.clone(); let errmsg1 = errmsg.clone();
let mut rt = tokio::runtime::Runtime::new().unwrap(); let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(async move { rt.block_on(async move {
let mut commando_sock = server::CommandoSocket::new(server::our_ctrl_sock()); let mut commando_sock = server::CommandoSocket::new(server::our_ctrl_sock());