Skip to content

fix: interactive ebook search lists results over 20 MB - #487

Merged
kikootwo merged 1 commit into
mainfrom
fix/323-ebook-size-cap
Oct 27, 2026
Merged

kikootwo merged 1 commit into
mainfrom
fix/323-ebook-size-cap

Conversation

@kikootwo

@kikootwo kikootwo commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

Closes #323

What changed

  • Ebook ranking (src/lib/utils/ranking-algorithm.ts): the 20 MB cap is now one exported constant, EBOOK_MAX_SIZE_MB, and rankEbookTorrents() takes a new option, enforceSizeCap (default true). With the cap on, results over 20 MB are skipped as before. With it off, they are kept, get a size score of 0 and the note ⚠️ Over 20 MB (automatic search skips it) in the score breakdown the API returns. The list itself shows their size, as for other results.
  • Interactive search: both routes (src/app/api/audiobooks/[asin]/interactive-search-ebook/route.ts and src/app/api/requests/[id]/interactive-search-ebook/route.ts) pass enforceSizeCap: false, so a large result is listed with its size like any other.
  • Automatic search (src/lib/processors/search-ebook.processor.ts) passes enforceSizeCap: true explicitly, and its log lines use the constant.
  • Anna's Archive results never had a size cap; that is unchanged.
  • No new setting or environment variable.
  • Docs: documentation/integrations/ebook-sidecar.md (Filtering, new Fixed Issues entry) and documentation/phase3/ranking-algorithm.md (Size Quality, the options interface, the comparison table, Fixed Issues).

Why

The cap was applied inside rankEbookTorrents() in every mode. A PDF with images, or any ebook over 20 MB, was dropped before the results reached the interactive search list, so when it was the only result the search showed nothing and gave no reason. Automatic search should still skip these (a large file is often not the ebook), but in interactive search the user is choosing and can see the size.

Evidence

  • tests/utils/ranking-ebook-size-cap.test.ts: rankEbookTorrents() skips a 35 MB result by default and with enforceSizeCap: true, lists it with enforceSizeCap: false (size kept, size score 0, the note), scores a 5 MB result the same either way, and at the boundary keeps exactly 20 MB and skips 20 MB plus one byte only when the cap is on.
  • tests/api/interactive-search-ebook-size-cap.routes.test.ts: both interactive routes, with the real ranking, return the 35 MB, 5 MB and 20 MB plus one byte results with their sizes.
  • tests/processors/search-ebook-size-cap.test.ts: automatic search with the real ranking skips a 35 MB result and one a byte over 20 MB, downloads a result of exactly 20 MB, and picks the 5 MB result over the 35 MB one.
  • With main's src (92b96cd) and the three new test files: 5 failed, 5 passed. All 5 fail on an assertion (the 35 MB and over-cap results missing from both routes and from the uncapped ranking, and the constant not exported). The 4 automatic search tests and the 5 MB test pass on main: they pin behaviour that does not change.
  • On this branch: 10/10 pass.

Checks

  • Unit tests for the changed code (vitest related on the four changed src files, plus the three new test files): PASS, 93 files, 1804/1804
  • Type check and lint: PASS (tsc --noEmit clean; ESLint reports nothing new in the touched files compared with main, and the new files are clean)
  • Image build and E2E smoke (npm run e2e -- --specs smoke, image built from e15870f): PASS, 1 passed
  • Full unit suite: PR Tests (CI)

Risk and rollback

  • Automatic search is unchanged: the same results are skipped and the same result is picked.
  • Interactive ebook search can now list results over 20 MB. They score 0 for size, so they rank below an otherwise equal smaller result.
  • Rollback: revert this PR. Nothing stored changes.

Release note

🤖 Generated with Claude Code

The 20 MB ebook cap in rankEbookTorrents applied in every mode, so a large
PDF that was the only indexer result left interactive search empty. The cap
is now EBOOK_MAX_SIZE_MB with an enforceSizeCap option (default true):
automatic search keeps skipping larger results, and both interactive routes
list them with their size (size score 0, an "Over 20 MB" note).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kikootwo
kikootwo marked this pull request as ready for review October 27, 2026 09:47
@kikootwo
kikootwo merged commit 333c88e into main Oct 27, 2026
1 check passed
@kikootwo
kikootwo deleted the fix/323-ebook-size-cap branch October 27, 2026 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Hardcoded Ebook Size Limit

1 participant