Quote:
Originally Posted by BetterRed
The following is: a) speculation, and b) is from the perspective of the GUI, but as you no doubt realise there's a lot of code sharing between the GUI library manager and the command line tools.
When a book's metadata is created/updated the new data is written to the relevant database tables and and to the metadata.opf file in the book folder. If the changes are made via the metadata edit dialogues the writes to the database tables and the write of the metadata.opf file** is done when the OK button is pressed.
But, if you edit in the book list using the F2 key and Tab I'm pretty sure the writes are done for each cell edited - so if you press F2 on Rating, enter a value and press Tab, the books rating value is written to the database and a fresh metadata.opf file is written; then if you enter some Tags and press Tab, the Tag values are written to the database and a fresh metadata.opf file is written… so on and so forth. I'm wondering if the calibredb set-metadata command works in a similar way.
** metadata.opf writes
Metadata value alterations can cascade though many books, e.g. a spelling correction of 'Vapmires' to Vampires' will generate one write to the database, but every book tagged with 'Vapmires' will get a fresh metadata.opf file with the correct tag value - i.e Vampires'.
To avoid long delays waiting for many fresh metadata.opf files to be written, fresh metadata.opf files are always written in a 'slow' background thread (some call them 'lazy writes'). On my rig they chug along at about one a second.
IIRC the calibredb backup_metadata command (without the '--all' option) will flush through any outstanding writes in the queue - might be worth giving it a try.
BR
|
I've seen that, regarding individual cell edits. I did wonder that it took so long to commit changes, but having to rewrite the OPF... well, I would expect it wouldn't take
long, but it would be non-zero time. It's clearly not as efficient as opening the metadata editor window and updating a bunch of fields at once.
What I'm referring to, though... I've got calibre configured to add a 'new book' tag to each title as it's added. I use this during batch loads so I can see the new entries easily, without having to remember the last time I cleansed my input. I clean the new books up, in this case assigning a 'characters' custom field. I update a few hundred books in a session (because I'm like that), remove the 'new book' tag, and close calibre.
I can reopen calibre and add new books, and it behaves normally.
When I try to add a new book via calibredb, it can take several minutes (in one case a couple hours) to get the first one into that library, and then it behaves normally. If I use calibredb to add the new title to a library where I have not done this, it behaves normally.
As best I can tell it seems to be trying to adapt to the large volume of changes. I have no explanation as to why this is so, and it baffles me. I can work around it, of course, but if there's something simple I can do to prevent it I'd be happy to learn it.