stapix

Yet another static page generator for photo galleries

Commit
114e44204990754bac9e392cc5ce5986ad4260c5
Parent
6e52def73c8b63e3891ab5a0131d06a011a076f5
Author
Pablo <pablo-escobar@riseup.net>
Date

Clamped the number of rendering threads

Diffstat

2 files changed, 3 insertions, 2 deletions

Status File Name N° Changes Insertions Deletions
Modified Cargo.toml 2 1 1
Modified src/main.rs 3 2 1
diff --git a/Cargo.toml b/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "stapix"
-version = "0.1.0"
+version = "0.1.1"
 edition = "2021"
 license = "GPLv3"
 
diff --git a/src/main.rs b/src/main.rs
@@ -1,6 +1,7 @@
 use crossterm::style::Stylize;
 use image::{DynamicImage, io::Reader as ImageReader};
 use std::{
+    cmp::min,
     env,
     fmt::{self, Display},
     fs::{self, File},
@@ -187,7 +188,7 @@ fn render_gallery(pics: Vec<Picture>) -> ExitCode {
     }
 
     // ========================================================================
-    let num_threads = num_cpus::get() + 1;
+    let num_threads = min(num_cpus::get() + 1, pics.len());
     let rendering_pool = ThreadPool::with_name(
         String::from("thumbnails renderer"),
         num_threads