diff --git a/main.lua b/main.lua index 6591c13..b4f6d07 100644 --- a/main.lua +++ b/main.lua @@ -1186,17 +1186,36 @@ function Bookhoard:_linkBookThenPull(interactive) end if result and result.status == 404 then - -- Genuinely unknown to the server (sideloaded book). The - -- legacy push-bootstrap only ever linked such books via fuzzy - -- title/author matching; keep that as a background attempt, - -- but tell interactive users to push explicitly. - if interactive then - UIManager:show(InfoMessage:new{ - text = _("This book is not in your Bookhoard library yet. Push progress to link it."), - timeout = 4, - }) + -- Two very different failures share this status. The server's + -- resolve handler answers a book miss with JSON + -- {"error": "book not found"}; anything else behind a 404 + -- (an HTML error page) means the route itself is missing — + -- a server image predating the resolve endpoint, a reverse + -- proxy, or a wrong server URL. Only the former may advise + -- pushing to link: acting on a stale-server 404 would push + -- this device's first-page position over the server's real + -- progress — the very conflict this flow exists to prevent. + if result.error == "book not found" then + -- Genuinely unknown to the server (sideloaded book). The + -- legacy push-bootstrap only ever linked such books via + -- fuzzy title/author matching; keep that as a background + -- attempt, but tell interactive users to push explicitly. + if interactive then + UIManager:show(InfoMessage:new{ + text = _("This book is not in your Bookhoard library yet. Push progress to link it."), + timeout = 4, + }) + else + self:_bootstrapUUIDThenPull(interactive) + end else - self:_bootstrapUUIDThenPull(interactive) + logger.warn("Bookhoard: resolve endpoint returned 404 without a book-not-found body (stale server?)") + if interactive then + UIManager:show(InfoMessage:new{ + text = _("Your Bookhoard server does not support this request and may be outdated. Update the server and try again."), + timeout = 5, + }) + end end return end