View Single Post
Old 01-14-2024, 10:55 AM   #1
LuisNeto
Member
LuisNeto began at the beginning.
 
Posts: 13
Karma: 10
Join Date: May 2022
Device: Kobo Libra 2
Launching E-book viewer restores deleted annotations / highlights

I am working on the development of a program for importing highlights from Kobo e-readers into calibre, and I've encountered a problem due to how calibre manages deleted annotations.

This program works by inserting the highlights into calibre's Annotations database table.
When I open calibre, I can see the highlights in "Browse annotations" and the E-book viewer.

However, I start getting problems after deleting highlights in calibre.

When a highlight is deleted, calibre updates the value of annot_data with an indication that it has been removed.

When I run the program to import the highlights again, it gets this database record, verifies that its JSON in annot_data (which says it's removed) is different from the JSON containing the highlight data from the e-reader, so it updates the database record with the highlight data again, overwriting the JSON that calibre had written (which indicated it was removed).

When I launch calibre, if I click in "Browse annotations" I can see the highlight.
But when I launch the e-book viewer, the highlight does not re-appear.

I then refresh the Annotations browser, the highlight is gone.
I check the Annotations database table again, I see that calibre has updated annot_data in that record with the JSON of a deleted record.

I have deleted the OPF file of the book in the library folder after syncing the highlights and before re-opening calibre.

I have also disabled the option for keeping a copy of annotations/bookmarks in the e-pub file (which I found out about thanks to this thread).
I had this option previously enabled, so I edited the EPUB and I deleted the calibre.bookmarks.txt file inside it.

Despite all of this, calibre is keeping highlights data somewhere and restores it when the E-Book viewer is launched.
Where is calibre storing this data, and why does it bring it back?

Thanks in advance.
LuisNeto is offline   Reply With Quote