Only Sync if Newer
elmodor opened this issue · 6 comments
Feature Request
It would be really cool if the plugin would only sync if the data from koreader is newer than the data currently stored in calibre.
Usecase
I have two devices where I read on.
If I read a book to 50% on device A, sync it the percent read is set to 50.
Then connect device B where the book is still at 20% because it was not opened/synced by koreader, sync it to calibre the percent read is changed to 20.
This should not happen and the sync should be aborted because the data in calibre is newer.
Similar Implementations
I took a look at how Kobo Utils does this:
They have a setting store_if_more_recent
and check the current_last_read
vs the new_last_read
status (in their jobs.py file). This can only be done if the last_read
is stored in a column.
Possible Implementation
I assume the last read date is equal to the date_sidecar_modified
field which is already implemented in the latest beta.
A new setting could be introduced similar to Kobo Utils: Sync only if more recent
If this settings is checked, and the date_sidecar_modified
is stored in a column, it can be checked if the date_sidecar_modified
from the devices koreader is newer than the stored date_sidecar_modified
. If it is older, sync_to_calibre
(action.py) should not call update_metadata
for that current book.
I was able to implement the settings part (a checkbox in the config menu) but I got stuck when I wanted to use the date_sidecar_modified
.
How is this supposed to work with a wireless connected device?
parsed_contents['calculated']['date_sidecar_modified'] = datetime.fromtimestamp(
os.path.getmtime(path)).replace(tzinfo=local_tz
)
os.path.getmtime
will call a path on my PC not on the wireless connected device. The path
is something like Book.sdr/metadate.epub.lua
which does not exist.
I think the only way to get this data is if koreader writes a timestamp/last read state into the metadata file.
Also see #2 (comment)
How does this relate to #8? Do we need this issue to work on an improvement for wirelessly connected devices? Or may it be closed?
While I added the ability to "sync only if more recent" in #8 it does not work for (at least) wireless connected devices because the mtime
can not be obtained of the sidecar file.
That is why I added the "fallback" for this option in case no newdate_modified
is obtainable (e.g. for wireless devices) where it does not compare the mtime
and instead compares the read_percent
if available. Only syncs if read_percent
is larger than the stored one.
To properly obtain the last modified date for all cases (wireless, and I guess SD card too?) either koreader needs to store this info inside the sidecar as well or we have to get access to the history.lua
file as mentioned in #2
going to close since no response from the author, let me know if you still have this issue