diff options
| author | A Farzat <a@farzat.xyz> | 2026-03-10 14:19:43 +0300 |
|---|---|---|
| committer | A Farzat <a@farzat.xyz> | 2026-03-10 14:19:43 +0300 |
| commit | 4e5f5e7d1d7a5738b34db79fe18e84582cb08233 (patch) | |
| tree | be2f7ff8d81f21777046e9c657683bdb5a989c30 /src/epub.rs | |
| parent | 1383c7be1b559520cebb3240f835d938c197d49f (diff) | |
| download | oreilly-epub-4e5f5e7d1d7a5738b34db79fe18e84582cb08233.tar.gz oreilly-epub-4e5f5e7d1d7a5738b34db79fe18e84582cb08233.zip | |
Make maximum parallel downloads configurable
Still limit it to 8 as more is ineffective and could trigger O'Reilly.
Diffstat (limited to 'src/epub.rs')
| -rw-r--r-- | src/epub.rs | 6 |
1 files changed, 2 insertions, 4 deletions
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<W: Write>(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)); } |
