Use try_for_each_with
in Installer::install
to avoid using a mutex
on the Sender.
This commit is contained in:
parent
d3b5d096e5
commit
c36b3b14ab
@ -1,8 +1,6 @@
|
|||||||
use hpk_package::deku::DekuError;
|
|
||||||
|
|
||||||
use {
|
use {
|
||||||
crate::{Item, ItemError, Package, Plist, Specs},
|
crate::{Item, ItemError, Package, Plist, Specs},
|
||||||
hpk_package::{tar, Entry},
|
hpk_package::{deku::DekuError, tar, Entry},
|
||||||
rayon::prelude::{IntoParallelRefIterator, ParallelIterator},
|
rayon::prelude::{IntoParallelRefIterator, ParallelIterator},
|
||||||
std::{
|
std::{
|
||||||
borrow::BorrowMut,
|
borrow::BorrowMut,
|
||||||
|
@ -100,9 +100,9 @@ impl<T: io::Read> Installer<T> {
|
|||||||
pr_node.write(writer)?;
|
pr_node.write(writer)?;
|
||||||
let path = &self.path;
|
let path = &self.path;
|
||||||
let package = &self.package;
|
let package = &self.package;
|
||||||
let sender = Mutex::new(sender);
|
|
||||||
let hooks = Mutex::new(hooks);
|
let hooks = Mutex::new(hooks);
|
||||||
archive.nodes.par_iter().try_for_each(|node| {
|
let s = sender.clone();
|
||||||
|
archive.nodes.par_iter().try_for_each_with(s, |sender, node| {
|
||||||
let mut path = path.clone();
|
let mut path = path.clone();
|
||||||
let fpath = node.header.file_path()?;
|
let fpath = node.header.file_path()?;
|
||||||
if let Some(s) = node.header.prefix() {
|
if let Some(s) = node.header.prefix() {
|
||||||
@ -153,7 +153,7 @@ impl<T: io::Read> Installer<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let msg = extract_entry(entry, node, path)?;
|
let msg = extract_entry(entry, node, path)?;
|
||||||
sender.lock().unwrap().send(msg)?;
|
sender.send(msg)?;
|
||||||
Ok::<(), InstallError>(())
|
Ok::<(), InstallError>(())
|
||||||
})?;
|
})?;
|
||||||
Ok(hooks.into_inner()?)
|
Ok(hooks.into_inner()?)
|
||||||
@ -252,6 +252,7 @@ fn pop_pinstall(
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod error {
|
mod error {
|
||||||
|
use crate::Hooks;
|
||||||
use hpk_package::tar;
|
use hpk_package::tar;
|
||||||
use std::{
|
use std::{
|
||||||
error::Error,
|
error::Error,
|
||||||
@ -262,9 +263,6 @@ mod error {
|
|||||||
PoisonError,
|
PoisonError,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::Hooks;
|
|
||||||
|
|
||||||
use super::InstallMessage;
|
use super::InstallMessage;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
Loading…
Reference in New Issue
Block a user