View Single Post
Old 05-25-2020, 10:02 AM   #4
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,461
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by pazos View Post
Hi chaley, thanks for your help.

When calibre sends the opcode "SEND_BOOK" I check if the book fits in the device. If it fits then I store it on disk and update my local database accordly.

calibre expects a client response per book. I send an opcode "OK" and no data if the book was stored fine. I would like to know how to notify calibre that a specific book in a batch was not received by the client. I tried to send "NOOP" but calibre thinks the book is on device until I disconnect the client and connect it again.
The protocol is weak here. The response to SEND_BOOK is processed before the book is actually sent and there is no way to tell the driver not to send the book. FYI: the response is used to tell calibre the device path (lpath) in case the device changes it.

I have to be very careful about what I change in order to avoid breaking other clients. That said, I can do two things, tested using CC:
  • If the client returns ERROR (val 20) to SEND_BOOK then the driver will raise a ControlError exception. The return dict can contain an entry 'message' that will be included in the exception. In this case the driver will not start sending the book data.
  • Add the sanity check that checks device free space against the book size(s)
I have committed the above changes. Once Kovid accepts them then they will be in calibre source for you to test.
chaley is offline   Reply With Quote