_doGetProgress ran every pull through the same forward/backward strategy
gate as the automatic flows (pull-on-open, periodic). With the default
sync_backward = DISABLE, a manual "Pull progress from server" on a book
where the server sat BEHIND the device hit the backward branch, matched
neither SILENT nor PROMPT, and silently did nothing: no prompt, no
message, no navigation. Reported against the Bookhoard server's KOReader
integration (Sense and Sensibility: device at XXXIX, server web reader
at VIII; the server correctly served the converted xpointer
/body/DocFragment[10]/body/div[1]/h2[1] per its logs — the pull reply
was consumed and then dropped by the gate).
An explicit user pull is 'take me to the server position', so it now
bypasses the strategies entirely: syncToProgress + _showSyncedMessage.
The equal-percentage 'already synchronized' early-out is unchanged.
Automatic pulls keep their existing behavior:
- forward/backward SILENT: apply silently
- forward/backward PROMPT: ConfirmBox with the computed target page
- DISABLE: silent skip (intended for pull-on-open / auto-sync)
Verified with a stubbed-KOReader harness driving _doGetProgress through
seven scenarios (manual behind/ahead/equal/no-locator, automatic
SILENT/PROMPT/DISABLE).
Server behavior untouched.
Every push and pull runs deferred — updateProgress and getProgress hand
their work to UIManager:scheduleIn(0.5), and API replies are consumed in
UIManager:nextTick closures — so by the time the task runs, the ReaderUI
may have released its document (close/teardown race) or a slow async
load may not have attached it yet (the CRE full-render window: "cached
rendering is invalid" leaves the reader document-less for seconds on
big EPUBs). The task then dereferenced self.ui.document unguarded and
the unhandled error inside a UIManager task killed the whole app:
main.lua:846: attempt to index field 'document' (a nil value)
...in function 'collectBookData'
...in function '_doUpdateProgress'
...in function 'action' (uimanager _checkTasks)
Observed as a hard crash on the auto-push (pages_before_update = 2)
right after opening an EPUB that needed a full re-render.
getBookhoardUUID and getContextText already nil-guarded their document
access; the task entry points never did. Guard them:
- _doUpdateProgress: bail before collectBookData — the single choke
point for every push source (periodic, close, suspend, menu, the
legacy bootstrap push), so one guard covers the whole class
- _doGetProgress: bail at entry, and re-validate first thing inside the
nextTick closure (its body and applyServerAnnotations touch
document.info long after the request was issued)
- getFileSHA256: return nil instead of indexing doc_settings/document
(all callers already handle nil)
No sync-payload or endpoint changes; server behavior untouched.