aboutsummaryrefslogtreecommitdiff
path: root/src/epub.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/epub.rs')
-rw-r--r--src/epub.rs13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/epub.rs b/src/epub.rs
index f9a5aac..c455671 100644
--- a/src/epub.rs
+++ b/src/epub.rs
@@ -8,7 +8,7 @@ use relative_path::{RelativePath, RelativePathBuf};
use reqwest::Client;
use std::{
collections::HashMap,
- io::{Read, Write},
+ io::{BufReader, Read, Write},
path::Path,
};
use tokio::{
@@ -107,21 +107,20 @@ pub fn create_epub_archive(
for entry in file_entries {
zip.start_file(&entry.full_path, options)?;
let mut src_file = std::fs::File::open(entry.full_path.to_path(epub_root))?;
- let mut buffer = Vec::new();
- src_file.read_to_end(&mut buffer)?;
if let Some(chapter) = chapters.get(&entry.ourn) {
let chapter_dir = entry.full_path.parent().unwrap_or(RelativePath::new(""));
- let html = String::from_utf8(buffer)?;
- let html = build_epub_chapter(
+ build_epub_chapter(
epub_data,
chapter,
chapter_dir,
- &html,
+ BufReader::new(src_file),
&url_to_file,
&url_path_to_local,
+ &mut zip,
)?;
- zip.write_all(html.as_bytes())?;
} else {
+ let mut buffer = Vec::new();
+ src_file.read_to_end(&mut buffer)?;
zip.write_all(&buffer)?;
}
}