Sync viewer navigation with browser sorting

This commit is contained in:
burnintuna 2026-07-22 03:01:12 +09:00
parent bb73c1abea
commit f0d5cf3496
5 changed files with 375 additions and 87 deletions

View file

@ -6,7 +6,7 @@ use anyhow::{Context, Result, bail};
use image::ImageReader;
use zip::ZipArchive;
use crate::browser::natural_cmp;
use crate::browser::natural_cmp_with_case;
const MAX_ENTRY_SIZE: u64 = 256 * 1024 * 1024;
const MAX_IMAGE_DIMENSION: u32 = 30_000;
@ -24,7 +24,7 @@ pub struct DecodedPage {
pub rgba: Vec<u8>,
}
pub fn list_pages(path: &Path) -> Result<Vec<ArchivePage>> {
pub fn list_pages(path: &Path, case_insensitive: bool) -> Result<Vec<ArchivePage>> {
let file = File::open(path)
.with_context(|| format!("ZIP 파일을 열 수 없습니다: {}", path.display()))?;
let mut archive = ZipArchive::new(file)
@ -41,7 +41,7 @@ pub fn list_pages(path: &Path) -> Result<Vec<ArchivePage>> {
}
}
pages.sort_by(|left, right| natural_cmp(&left.name, &right.name));
pages.sort_by(|left, right| natural_cmp_with_case(&left.name, &right.name, case_insensitive));
Ok(pages)
}
@ -178,7 +178,7 @@ mod tests {
archive.write_all(b"ignored").unwrap();
archive.finish().unwrap();
let pages = list_pages(&path).unwrap();
let pages = list_pages(&path, true).unwrap();
assert_eq!(
pages
.iter()