Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Arne
2026-08-08 13:40:23 +02:00
committed by GitHub
co-authored by Copilot Autofix powered by AI
parent e5931aa5c7
commit 15d323541c
+23 -7
View File
@@ -97,17 +97,33 @@ func (s *Service) FindBook(id string) (*Book, error) {
}
func (s *Service) CoverBytes(id string) ([]byte, string, error) {
book, err := s.FindBook(id)
if id == "" {
return nil, "", nil
}
entries, err := os.ReadDir(s.booksDir)
if err != nil {
if os.IsNotExist(err) {
return nil, "", nil
}
return nil, "", err
}
if book == nil {
return nil, "", nil
for _, e := range entries {
if e.IsDir() {
continue
}
ext := strings.ToLower(filepath.Ext(e.Name()))
if ext != ".epub" {
continue
}
if stableID(e.Name()) != id {
continue
}
return readEPUBCover(filepath.Join(s.booksDir, e.Name()))
}
if book.Format != "epub" {
return nil, "", nil
}
return readEPUBCover(book.Path)
return nil, "", nil
}
func stableID(input string) string {