fix: limit concurrent thumbnail generation (#1138)

This commit is contained in:
Ashley Wulber 2025-08-13 13:00:07 -04:00 committed by GitHub
parent e3c793a44d
commit a4e3bf3eea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 0 deletions

View file

@ -95,6 +95,11 @@ const MAX_SEARCH_RESULTS: usize = 200;
//TODO: configurable thumbnail size?
const THUMBNAIL_SIZE: u32 = (ICON_SIZE_GRID as u32) * (ICON_SCALE_MAX as u32);
pub static THUMB_SEMAPHORE: LazyLock<tokio::sync::Semaphore> = LazyLock::new(|| {
tokio::sync::Semaphore::const_new(num_cpus::get())
});
pub(crate) static SORT_OPTION_FALLBACK: LazyLock<HashMap<String, (HeadingOptions, bool)>> =
LazyLock::new(|| {
HashMap::from_iter(dirs::download_dir().into_iter().map(|dir| {
@ -5634,6 +5639,7 @@ impl Tab {
let message = {
let path = path.clone();
_ = THUMB_SEMAPHORE.acquire().await;
tokio::task::spawn_blocking(move || {
let start = Instant::now();
let thumbnail = ItemThumbnail::new(