janeczku / calibre-web

:books: Web app for browsing, reading and downloading eBooks stored in a Calibre database
GNU General Public License v3.0
12.93k stars 1.38k forks source link

Kobo sync only removes books from collection, not the device #2685

Open dregin opened 1 year ago

dregin commented 1 year ago

After removing a book from a shelf in Calibre-Web and running a sync on my kobo, I see the book removed from the Collection on the device, but it still exists under "My Books".

I'm expecting it to be completely removed from the device, if it's not on a shelf that Calibre-web is configured to sync to kobo.

Any ideas how to fix this?

Thanks!

snppls commented 4 months ago

Did you ever work out how to do this? I am in the same situation.

user34756361233 commented 3 months ago

Run into the same. But when checking this link: https://github-wiki-see.page/m/janeczku/calibre-web/wiki/Kobo-Integration

Deleting a book from Calibre/Calibre-Web will not cause it to be removed from the device on the next Sync. In order to trigger deletions from their devices, users must archive books and then sync their devices.

I think this is the case, although I would like to have the OP behaviour.

jorritsmit commented 2 months ago

that's indeed undesired behaviour. if i want to remove books from my device, doesn't mean i want to remove them from my server. I also noticed that if you do remove the book manually from your kobo and want sync it back on (so add it again to the kobo shelve) the book is not synced (probably because some list is kept of what was already synced to the ereader)

jorritsmit commented 2 months ago

I looked a bit around the code and i think i found the following things:

  1. the problem i had with the book i manually removed, not being synced again, can be solved by doing a full resync in the admin page
  2. When processing the request for a kobo sync, there is a query made on the database for changed entries https://github.com/janeczku/calibre-web/blob/ca92dbb168164c90377c146c87cd5e9a6247d546/cps/kobo.py#L175 and from this list book entitlements are updated or created. https://github.com/janeczku/calibre-web/blob/ca92dbb168164c90377c146c87cd5e9a6247d546/cps/kobo.py#L214 I think these entitlements is what the kobo api uses to sync the books. If i see correctly in: https://github.com/janeczku/calibre-web/blob/ca92dbb168164c90377c146c87cd5e9a6247d546/cps/kobo.py#L374 uses the archived state of the book (i guess archived in calibre-web) to set the book as archived on the ereader, which is how kobo requests a deletion from the e-reader i guess.

assuming this is all correct, wouldn't it be possible to check the previous list of entitlements/synced books and compare it to the current. If a book is not on the new list but was on the old one set archived=True in the entitlement?

i am asking because if this is correct and desired behaviour i can make a PR