Repository navigation
fix: interactive ebook search lists results over 20 MB - #487
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #323
What changed
src/lib/utils/ranking-algorithm.ts): the 20 MB cap is now one exported constant,EBOOK_MAX_SIZE_MB, andrankEbookTorrents()takes a new option,enforceSizeCap(defaulttrue). 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.src/app/api/audiobooks/[asin]/interactive-search-ebook/route.tsandsrc/app/api/requests/[id]/interactive-search-ebook/route.ts) passenforceSizeCap: false, so a large result is listed with its size like any other.src/lib/processors/search-ebook.processor.ts) passesenforceSizeCap: trueexplicitly, and its log lines use the constant.documentation/integrations/ebook-sidecar.md(Filtering, new Fixed Issues entry) anddocumentation/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 withenforceSizeCap: true, lists it withenforceSizeCap: 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.main'ssrc(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 onmain: they pin behaviour that does not change.Checks
vitest relatedon the four changedsrcfiles, plus the three new test files): PASS, 93 files, 1804/1804tsc --noEmitclean; ESLint reports nothing new in the touched files compared withmain, and the new files are clean)npm run e2e -- --specs smoke, image built from e15870f): PASS, 1 passedRisk and rollback
Release note
🤖 Generated with Claude Code