From 4e5f5e7d1d7a5738b34db79fe18e84582cb08233 Mon Sep 17 00:00:00 2001 From: A Farzat Date: Tue, 10 Mar 2026 14:19:43 +0300 Subject: Make maximum parallel downloads configurable Still limit it to 8 as more is ineffective and could trigger O'Reilly. --- src/epub.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/epub.rs') diff --git a/src/epub.rs b/src/epub.rs index 1e7402e..050e9cf 100644 --- a/src/epub.rs +++ b/src/epub.rs @@ -16,9 +16,6 @@ use tokio::fs::{self, File}; use tokio_util::io::StreamReader; use zip::{CompressionMethod, ZipWriter, write::FileOptions}; -// TODO: make configurable. -const MAX_CONCURRENT: usize = 4; - /// Creates and writes container.xml. fn write_container_xml(out: &mut W, opf_full_path: &RelativePathBuf) -> Result<()> { // Prepare file contents. @@ -41,12 +38,13 @@ pub async fn download_all_files( client: &Client, file_entries: &[FileEntry], dest_root: &Path, + max_concurrent: usize, ) -> Result<()> { let mut downloading = FuturesUnordered::new(); let mut files_iter = file_entries.iter(); // Start downloading the first n files. - for entry in files_iter.by_ref().take(MAX_CONCURRENT) { + for entry in files_iter.by_ref().take(max_concurrent) { downloading.push(download_one_file(client, entry, dest_root)); } -- cgit v1.2.3-70-g09d2