fix(reader): harden KOReader sync and credential refresh

Sanitize match-check batches before strict server validation and classify HTTP failures accurately. Rebind the active catalog client whenever authentication settings change so retries use current credentials.

Fixes #1150
This commit is contained in:
neon
2026-08-28 15:29:36 +00:00
parent 3b44fa5d7e
commit f39e0e8ab5
10 changed files with 335 additions and 13 deletions
@@ -199,7 +199,7 @@ local function finish(ctx, err)
end
if ctx.plugin and ctx.plugin.recordSyncError then
if err == "auth" or err == "network" then
if err == "auth" or err == "network" or err == "server" then
ctx.plugin:recordSyncError("sweep", err)
elseif not err and ctx.had_errors then
ctx.plugin:recordSyncError("sweep", "partial_failure")
@@ -243,6 +243,17 @@ local function finish(ctx, err)
return
end
if err == "server" then
if ctx.interactive then
UIManager:show(InfoMessage:new{ text = _("BookOrbit sync: server request failed."), timeout = 4 })
end
logger.warn("BookOrbit: sweep aborted, server request failed")
if ctx.on_finish then
pcall(ctx.on_finish, err)
end
return
end
if ctx.interactive then
local text = T(_("BookOrbit sync done: %1 books matched, %2 reading events, %3 highlights."),
ctx.counts.books_matched, ctx.counts.page_stats, ctx.counts.annotations)
@@ -606,6 +617,7 @@ local function stepMatchNext(ctx)
if aborted(ctx) then return end
if not body then
if isAuthError(err) then return finish(ctx, "auth") end
if type(err) == "number" then return finish(ctx, "server") end
return finish(ctx, "network")
end