diff options
author | metamuffin <metamuffin@disroot.org> | 2023-10-04 10:18:52 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-10-04 10:18:52 +0200 |
commit | 8d3faa3d3d765441a0753748c92079db08fb8374 (patch) | |
tree | d40d9b8ec0e1145d33577aa7eb4f4504c7a1c416 /transcoder/src/image.rs | |
parent | 520051f3319b5ba4e811d43b5ce3554761653df3 (diff) | |
download | jellything-8d3faa3d3d765441a0753748c92079db08fb8374.tar jellything-8d3faa3d3d765441a0753748c92079db08fb8374.tar.bz2 jellything-8d3faa3d3d765441a0753748c92079db08fb8374.tar.zst |
limit number of local transcoding tasks
Diffstat (limited to 'transcoder/src/image.rs')
-rw-r--r-- | transcoder/src/image.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/transcoder/src/image.rs b/transcoder/src/image.rs index 06a2f80..3cd9986 100644 --- a/transcoder/src/image.rs +++ b/transcoder/src/image.rs @@ -1,3 +1,4 @@ +use crate::LOCAL_TRANSCODING_TASKS; use anyhow::Context; use image::{imageops::FilterType, ImageFormat}; use jellybase::{cache::async_cache_file, AssetLocationExt}; @@ -22,11 +23,10 @@ pub async fn transcode( &format!("{width} {quality} {speed}"), ], move |mut output| async move { + let _permit = LOCAL_TRANSCODING_TASKS.acquire().await?; + info!("encoding {asset:?} (speed={speed}, quality={quality}, width={width})"); let encoded = tokio::task::spawn_blocking(move || { let original_path = asset.path(); - info!( - "encoding {original_path:?} (speed={speed}, quality={quality}, width={width})" - ); // TODO shouldn't be neccessary with guessed format. let file = BufReader::new(File::open(&original_path).context("opening source")?); let mut reader = image::io::Reader::new(file); |