5.28 Forgets or reverts identifiers

Bug #1945098 reported by Disabled Reader
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
calibre
Fix Released
Undecided
Charles Haley

Bug Description

Calibre 5.28
Windows 11

I use the Goodreads Sync plugin to download the identifier links but calibre forgets or reverts when switching libraries.

1) Goodreads plugin: Link to Goodreads
2) Select from options show
3) Goodreads plugin: Switch Goodreads Edition
4) Identifiers are correct
5) Switch to another library and then switch back
6) The identifiers info is lost

Re-installed 5.27 and everything is fine.

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

Changing the component for this bug.

 assignee cbhaley
 status triaged

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

@charles: I am guessing this is caused by your changes to avoid writing
unchanged values, it's probably the plugin doing something unexpected
with the API, but...

Changed in calibre:
assignee: nobody → Charles Haley (cbhaley)
status: New → Triaged
Revision history for this message
Charles Haley (cbhaley) wrote :

@kovid: the root cause of the problem is that cache.field_for('identifiers') returns the dict from the table without making a copy. Thus when legacy.set_identifier() adds a new identifier to the dict it is changing base calibre data.

I can fix this by making legacy.set_identifier() make a copy of the dict before modifying it. However, that won't fix anywhere else that does field_for(), modify dict, set_field(). Note that if someone does a field_for() then modifies the dict then calibre will show modified values even if they were never written.

Seems to me that the right fix is to make a shallow copy in fields.IdentifiersField.for_book(). A deep copy isn't needed because the dict contains strings that are (I think) immutable. Are you OK with this or would your rather I change legacy.set_identifier()?

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

I submitted a PR with the copy in IdentifiersField.for_book() in case you are OK with that.

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

Also, as far as I can tell core calibre doesn't use legacy.set_identifer(). The problem is restricted to plugins.

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: Triaged → Fix Released
Revision history for this message
Kovid Goyal (kovid) wrote : Re: calibre bug 1945098

Yes, I agree this is restricted to plugins.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.