Skip to content

Commit

Permalink
small regression
Browse files Browse the repository at this point in the history
  • Loading branch information
sokorototo committed Jul 29, 2024
1 parent d8df3fc commit 6de18ad
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 28 deletions.
21 changes: 5 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions vach-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@ name = "vach"
path = "src/main.rs"

[dependencies]
vach = { version = "0.6", features = ["all"] }
vach = { version = "0.6.2", features = ["all"] }
num_cpus = "1.16.0"
clap = "3.1.15"
indicatif = "0.17.8"
anyhow = "1.0.81"
anyhow = "1.0.86"
tabled = "0.15.0"
walkdir = "2.5.0"
term_size = "0.3.2"
tempfile = "3.10.1"
3 changes: 1 addition & 2 deletions vach-cli/src/commands/pack.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::{
fs::File,
io::{self, Read, Write},
num::NonZeroUsize,
};
use std::path::PathBuf;
use std::collections::HashSet;
Expand Down Expand Up @@ -216,7 +215,7 @@ impl CommandTrait for Evaluator {
magic,
keypair: kp,
progress_callback: Some(&callback),
num_threads: `NonZeroUsize::new(num_threads).expect("Jobs can't be zero")`,
num_threads,
};

// Construct the builder
Expand Down
2 changes: 1 addition & 1 deletion vach/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "vach"

# NOTE: Make sure spec.txt and vach::VERSION constants are all synced up
version = "0.6.1"
version = "0.6.2"

edition = "2021"
authors = [
Expand Down
8 changes: 3 additions & 5 deletions vach/src/writer/config.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::{fmt::Debug, num::NonZeroUsize};

use crate::global::{flags::Flags, reg_entry::RegistryEntry};

#[cfg(feature = "crypto")]
Expand All @@ -10,7 +8,7 @@ use crate::crypto;
pub struct BuilderConfig<'a> {
/// Number of threads to spawn during `Builder::dump`, defaults to 4
#[cfg(feature = "multithreaded")]
pub num_threads: NonZeroUsize,
pub num_threads: usize,
/// Used to write a unique magic sequence into the write target.
pub magic: [u8; crate::MAGIC_LENGTH],
/// Flags to be written into the `Header` section of the write target.
Expand All @@ -36,7 +34,7 @@ pub struct BuilderConfig<'a> {
pub progress_callback: Option<&'a dyn Fn(&RegistryEntry)>,
}

impl<'a> Debug for BuilderConfig<'a> {
impl<'a> std::fmt::Debug for BuilderConfig<'a> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut f = f.debug_struct("BuilderConfig");

Expand Down Expand Up @@ -112,7 +110,7 @@ impl<'a> Default for BuilderConfig<'a> {
fn default() -> BuilderConfig<'a> {
BuilderConfig {
#[cfg(feature = "multithreaded")]
num_threads: NonZeroUsize::new(4).unwrap(),
num_threads: 4,
flags: Flags::default(),
magic: *crate::DEFAULT_MAGIC,
progress_callback: None,
Expand Down
3 changes: 2 additions & 1 deletion vach/src/writer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ impl<'a> Builder<'a> {
{
thread::scope(|s| -> InternalResult<()> {
let count = leafs.len();
let chunk_size = (leafs.len() / config.num_threads).max(leafs.len());
let chunk_size = leafs.len() / config.num_threads.min(1);

let chunks = leafs.chunks_mut(chunk_size);
let encryptor = encryptor.as_ref();

Expand Down

0 comments on commit 6de18ad

Please sign in to comment.