Fix ProgressSync last-synced date showing 22 Jan 1970 - #159
Open
vishae wants to merge 1 commit into
Open
Conversation
progress_data['timestamp'] comes straight from the KOReader sync server's GET /syncs/progress response, which stores it via Lua's os.time() (Unix seconds) - see koreader/koreader-sync-server's syncs_controller.lua. Dividing that by 1000 before passing it to datetime.fromtimestamp() treats a seconds value as milliseconds, producing a timestamp ~1000x too small: today's real epoch time (~1.78 billion seconds) becomes ~1.78 million seconds, which lands about 20 days after the epoch - displayed as 22 Jan 1970.
This was referenced Jul 12, 2026
Author
|
this PR fixes #163 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
column_date_syncedwas showing dates around 22 Jan 1970 instead of the real sync time.progress_data['timestamp']comes directly from the KOReader sync server'sGET /syncs/progress/:documentresponse. The reference server implementation (koreader/koreader-sync-server,syncs_controller.lua) stores this via Lua'sos.time(), i.e. plain Unix seconds:action.pywas dividing that value by 1000 before callingdatetime.fromtimestamp(), which is the correct conversion for milliseconds, not seconds:Today's real epoch time is roughly 1.78 billion seconds. Dividing that by 1000 gives ~1.78 million seconds, which lands about 20 days after the Unix epoch — displayed as 22 Jan 1970. This reproduces consistently regardless of which KOReader client wrote the progress, since the server always uses its own current time on write and this plugin's date math is what mangles it afterward.
Fix
Removed the
/1000—progress_data['timestamp']is already in seconds, which is whatdatetime.fromtimestamp()expects.Test plan
make test(viapytest tests/): 14/16 pass; the 2 pre-existing failures (test_version_match,test_version_tuple_match) are unrelated version-string sync checks that also fail on unmodifieddevelopHEAD.make lint(viapylint): 9.68/10 (above the 9.5 threshold), no new warnings on the changed line.timestampis written as Unix seconds, not milliseconds.