fix(sync): link fresh books via read-only SHA-256 resolve before first pull
Downloading a book from OPDS and opening it for the first time left the plugin without a cached bookhoard UUID, so it bootstrapped the book's identity by pushing once. That push carried the device's first-page position, which the server stored as a real progress update for a book that could be mid-read from another source — tripping the cross-source conflict detector and clobbering genuine progress before the first pull could deliver it. Until the conflict was resolved on the web, the device could not pull the correct progress at all. - onReaderReady now always pulls first; a pull no longer delegates to a push to learn the book's identity - new _linkBookThenPull: resolves the UUID with a read-only GET /api/sync/koreader/resolve?sha256= call (BookhoardAPI:resolveBook), caches it in the document sidecar, then performs the pull — the device's position is never transmitted - the legacy push-bootstrap survives only as a background fallback for books the server does not know by hash (404, sideloaded); interactive pulls are told to push explicitly instead Requires the server-side resolve endpoint (bookhoard feat(sync): add read-only KOReader book resolve endpoint).
This commit is contained in:
@@ -126,6 +126,13 @@ function BookhoardAPI:syncProgress(book_data, sync_mode)
|
||||
}, PROGRESS_TIMEOUTS)
|
||||
end
|
||||
|
||||
-- Read-only SHA-256 → book UUID lookup. Used to link a freshly downloaded
|
||||
-- book WITHOUT pushing progress (a push would transmit the device's
|
||||
-- first-page position and clobber/conflict with real server progress).
|
||||
function BookhoardAPI:resolveBook(sha256)
|
||||
return self:_request("GET", "/api/sync/koreader/resolve?sha256=" .. sha256, nil, PROGRESS_TIMEOUTS)
|
||||
end
|
||||
|
||||
function BookhoardAPI:getMetadata(uuid)
|
||||
return self:_request("GET", "/api/sync/koreader/metadata/" .. uuid, nil, PROGRESS_TIMEOUTS)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user