The fileExists() early-return skipped setting writableLibraryPath,
so relative --zimPathToSave resolved against CWD instead of the new
library's own directory when creating a library that doesn't exist yet.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Wrap the recurring kiwix::computeAbsolutePath(kiwix::removeLastPathElement(...), ...)
pattern in a small helper and use it in addBookFromPathAndGetIdTest.
totalResults/startIndex/itemsPerPage were parsed inside a try/catch,
but strtoull() never throws on malformed input, so a feed missing
those elements silently fell through with zeroed-out fields and no
way to distinguish "not a search result" from "search result of size
zero". Check each node's presence directly instead, and cover both
paths with new Manager tests.
The test data was modified so that support for catalog only mode
of kiwix-serve can be properly tested.
The effect of this change in the test data on the library_server unit
test demonstrates that although the new entry does not appear in the
catalog (for example, no catalog_v2_entries* test cases were affected)
the category and language of this ghost entry slipped into the
observable output.
We want to be sure that `Library` actually exists when we modify it.
While it is not a silver bullet (user can still create a shared_ptr on
a raw pointer), making the `Manager` keep `shared_ptr` on the library
help us a lot here.