annotation_count() displaying value for deleted annotations

Bug #1904305 reported by ownedbycats
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
calibre
Undecided
Unassigned

Bug Description

Calibre 5.5.0 (x64)

I have this set in a composite column:

program:
 if annotation_count() >0 then 'True'
 fi

It's returning "true" for a few books that have deleted bookmarks/annotations. I'm unsure whether I deleted those annotations in ebook-viewer or the annotation browser.

Revision history for this message
ownedbycats (ownedbycats) wrote :

I opened metadata.db in SQLite Spy and looked at the Annotations table. The removed annotations are still present in there (confirmed with book ID), although the annot_data begins with "removed":true.

description: updated
description: updated
Revision history for this message
ownedbycats (ownedbycats) wrote :

I'm unsure of whether deleted annotations need to remain in the database (I didn't attempt to test it), but perhaps a solution would be to remove the phantom annotations upon library cleanup.

Revision history for this message
ownedbycats (ownedbycats) wrote :

sorry, I mean "Check Library," when the vacuuming is done.

Revision history for this message
Kovid Goyal (kovid) wrote : Re: calibre bug 1904305

Yes, removed annotations need to remain. Without that syncing to
different places would not work. If you remove an annotation from
the calibre local viewer then that removal has to be synced to the
browser viewer and vice versa. Removed annotations is the mechanism this
is done by.

 status wontfix

Changed in calibre:
status: New → Won't Fix
Revision history for this message
ownedbycats (ownedbycats) wrote :

That makes annotation_count() a bit less useful though. Hm.

Revision history for this message
Charles Haley (cbhaley) wrote :

@Kovid: do you object to me changing annotation_count_for_book to:
        count = 0
        for (data,) in self.execute('SELECT annot_data FROM annotations WHERE book=?', (book_id,)):
            if '"removed": true' not in data:
                count += 1
        return count

I could unpack the json and check that but it seems that it takes time for no good reason.

Revision history for this message
Kovid Goyal (kovid) wrote :

@charles: There is JSON query sqlite extension, that IIRC is included in
calibre, might be faster to use that. Avoids a trip to python land.

Revision history for this message
Charles Haley (cbhaley) wrote :

Thanks. That extension is cool.

Changed in calibre:
status: Won't Fix → Fix Committed
Revision history for this message
Kovid Goyal (kovid) wrote : Fixed in master

Fixed in branch master. The fix will be in the next release. calibre is usually released every alternate Friday.

 status fixreleased

Changed in calibre:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers