summaryrefslogtreecommitdiffstats
path: root/src/app/app_context.rs
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2021-06-02 13:45:12 +0200
committerCanop <cano.petrole@gmail.com>2021-06-02 13:45:12 +0200
commit77f40f74c38392a5213f99006138d74772ac5c6c (patch)
tree145732e2e45e0dd3bf17e2a2f3e07027cc5d3338 /src/app/app_context.rs
parent7635373786d1c0fbc45c326d4a0a8914396f7051 (diff)
make the number of threads used for file summing configurable
Also replace lazy_static with once_cell
Diffstat (limited to 'src/app/app_context.rs')
-rw-r--r--src/app/app_context.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/app/app_context.rs b/src/app/app_context.rs
index 7af3502..adb27ad 100644
--- a/src/app/app_context.rs
+++ b/src/app/app_context.rs
@@ -4,6 +4,7 @@ use {
cli::AppLaunchArgs,
conf::Conf,
errors::ConfError,
+ file_sum,
icon::*,
pattern::SearchModeMap,
path::SpecialPath,
@@ -69,6 +70,10 @@ pub struct AppContext {
/// whether to quit broot when the user hits "escape"
/// and there's nothing to cancel
pub quit_on_last_cancel: bool,
+
+ /// number of threads used by file_sum (count, size, date)
+ /// computation
+ pub file_sum_threads_count: usize,
}
impl AppContext {
@@ -97,6 +102,11 @@ impl AppContext {
.transpose()?
.unwrap_or_default();
let ext_colors = ExtColorMap::try_from(&config.ext_colors)?;
+ let file_sum_threads_count = config.file_sum_threads_count
+ .unwrap_or(file_sum::DEFAULT_THREAD_COUNT);
+ if file_sum_threads_count < 1 || file_sum_threads_count > 50 {
+ return Err(ConfError::InvalidThreadsCount{ count: file_sum_threads_count });
+ }
let max_panels_count = config.max_panels_count
.unwrap_or(2)
.clamp(2, 100);
@@ -116,6 +126,7 @@ impl AppContext {
mouse_capture_disabled: config.disable_mouse_capture.unwrap_or(false),
max_panels_count,
quit_on_last_cancel: config.quit_on_last_cancel.unwrap_or(false),
+ file_sum_threads_count,
})
}
}