From 6782269bb52a349e9568a28ed6c1f43438b7bb24 Mon Sep 17 00:00:00 2001 From: A Farzat Date: Tue, 3 Mar 2026 14:16:45 +0300 Subject: Add container.xml to zip Instead of writing it to file and then reading it again, we write container.xml straight to zip, just like we did with mimetype. --- src/main.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index db1fdd4..8c5c712 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,7 +5,7 @@ mod models; use std::collections::HashMap; use std::path::Path; -use crate::epub::{download_all_files, write_container_xml}; +use crate::epub::{download_all_files,}; use crate::http_client::build_authenticated_client; use crate::models::{Chapter, EpubResponse, FileEntry, Paginated, SpineItem, TocNode}; use anyhow::{Context, Result, ensure}; @@ -112,16 +112,9 @@ async fn main() -> Result<()> { let spine_items: Vec = fetch_all_pages(&client, epub_data.spine.clone()).await?; let toc_vec: Vec = fetch_direct_array(&client, &epub_data.table_of_contents).await?; - // Find the OPF file entry to reference it in container.xml - let opf_entry = file_entries - .iter() - .find(|f| f.filename_ext == ".opf" && f.media_type == "application/oebps-package+xml") - .context("No OPF file with the correct MIME type was found.")?; - let dest_root = format!("Books/{}/epub_root", args.bookid); let dest_root = Path::new(&dest_root); download_all_files(&client, &file_entries, dest_root).await?; - write_container_xml(dest_root, &opf_entry.full_path).await?; // Sanity check: Every entry in spine exists in chapters. let chapters: HashMap = -- cgit v1.2.3-70-g09d2