feat(cbz): adapt reader to real archive structure — PageIndex skips macOS junk (__MACOSX/ and ._ AppleDouble were polluting pages with 163-byte blacks), pages endpoint derives chapters[{title,start}] from folder layout, imageless zip now lands state=error instead of an empty reader, CbzReader gains 目录 sidebar + prev/next chapter (TextReader pattern, rd-* classes); pagesidx cache key bumped for one-time invalidation; e2e on 311MB 調教開關:第二季.zip: 15048→7524 real pages, 52 chapters, all JPEGs
This commit is contained in:
@@ -26,6 +26,14 @@ func isImage(name string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// junkEntry: macOS 打包混入的资源叉垃圾(__MACOSX/ 目录与 ._* AppleDouble),不是页
|
||||
func junkEntry(name string) bool {
|
||||
if strings.HasPrefix(strings.ToLower(name), "__macosx/") {
|
||||
return true
|
||||
}
|
||||
return strings.HasPrefix(path.Base(name), "._")
|
||||
}
|
||||
|
||||
func PageIndex(f io.ReaderAt, size int64) ([]string, error) {
|
||||
zr, err := zip.NewReader(f, size)
|
||||
if err != nil {
|
||||
@@ -36,6 +44,9 @@ func PageIndex(f io.ReaderAt, size int64) ([]string, error) {
|
||||
if unsafeEntry(zf.Name) {
|
||||
return nil, fmt.Errorf("%w: %s", ErrUnsafeZip, zf.Name)
|
||||
}
|
||||
if junkEntry(zf.Name) {
|
||||
continue
|
||||
}
|
||||
if isImage(zf.Name) {
|
||||
names = append(names, zf.Name)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user