Leseratte10 / acsm-calibre-plugin

Calibre plugin for ACSM->EPUB and ACSM->PDF conversion.
https://www.mobileread.com/forums/showthread.php?t=341975
GNU General Public License v3.0
653 stars 23 forks source link

Adding lots of ACSM files at once doesn't populate loan list correctly #37

Closed Leseratte10 closed 1 year ago

Leseratte10 commented 1 year ago

Bug description

When adding multiple ACSM files from a library at once, the loaned book list isn't always populated correctly.

I suspect this is due to a race condition. When importing multiple books, Calibre seems to run multiple instances of the plugin at once.

This means when there's code like this (pseudocode):

then some records can get overwritten when they're created at the exact same time.

So, I need to add some kind of lock that only one instance of the plugin can mess with the loan list at once, and others will have to wait.

Bug first reported by @p1nkyy in https://github.com/Leseratte10/acsm-calibre-plugin/issues/31#issuecomment-1237581080

Operating system

Linux, Windows, MacOS

Which version of the DeACSM plugin are you running?

v0.0.16

Leseratte10 commented 1 year ago

This bug should now hopefully be fixed with commit b05e6314186274b12fa85203540daf524d0a806a. I don't have that many ACSM files to test, but I've imported a batch of three files multiple times, and it always worked correctly. Related to #31.

Please let me know if the issue still occurs with this change.

p1nkyy commented 1 year ago

Cool, one unrelated question when will v0.0.17 will be released and does Calibre 6.7.1 fixes the apostrophe thing? I will delete this comment once I got the answer. I want to ask in the forum instead but its captcha doesn't like my country / IP address.

Leseratte10 commented 1 year ago

EDIT: Calibre 6.7.1 does NOT fix the aposthrophe issue yet, that'll be in the next release.

And I don't know yet when the next plugin update will be released. The next version will change the plugin name from "DeACSM" to "ACSM Input" and that's a bit tricky and needs a ton of tests to make sure that works smoothly for everyone, as the Calibre plugin updater usually refuses to rename plugins without a couple tricks (see the README in the migration_plugin folder).

p1nkyy commented 1 year ago

EDIT: Calibre 6.7.1 does NOT fix the aposthrophe issue yet, that'll be in the next release.

And I don't know yet when the next plugin update will be released. The next version will change the plugin name from "DeACSM" to "ACSM Input" and that's a bit tricky and needs a ton of tests to make sure that works smoothly for everyone, as the Calibre plugin updater usually refuses to rename plugins without a couple tricks (see the README in the migration_plugin folder).

Thanks for your response. Can you kindly share the link to beta v 0.0.17 then. Would appreciate it.

Leseratte10 commented 1 year ago

You can always find the latest beta by going to the "Actions" tab, then clicking on the topmost workflow run, then scroll down to the bottom where it says "Artifacts", then click on the "calibre-plugins" entry.

For the current beta that'd be this one: https://github.com/Leseratte10/acsm-calibre-plugin/suites/8809255829/artifacts/400790201

That'll get you a ZIP and in there is another two ZIP files (calibre-plugin.zip and calibre-migration-plugin). The first one is the plugin ZIP you can import into Calibre.

p1nkyy commented 1 year ago

`calibre, version 6.6.1 ERROR: Unhandled exception: InvalidPlugin:Initialization of plugin Traceback (most recent call last): File "calibre\customize\ui.py", line 676, in initialize_plugin File "calibre_plugins.deacsm.init", line 164, in initialize File "calibre_plugins.deacsm.init", line 114, in init_embedded_plugins ImportError: cannot import name 'ACSMInputGUIExtension' from 'calibre_plugins.deacsm.gui_main_wrapper' (C:\Users\XYZ\AppData\Roaming\calibre\plugins\ACSM Input.zip/gui_main_wrapper.py) failed with traceback: Traceback (most recent call last): File "calibre\customize\ui.py", line 676, in initialize_plugin File "calibre_plugins.deacsm.init", line 164, in initialize File "calibre_plugins.deacsm.init", line 114, in init_embedded_plugins ImportError: cannot import name 'ACSMInputGUIExtension' from 'calibre_plugins.deacsm.gui_main_wrapper' (C:\Users\XYZ\AppData\Roaming\calibre\plugins\ACSM Input.zip/gui_main_wrapper.py)

calibre 6.6.1 embedded-python: True Windows-10-10.0.19043-SP0 Windows ('64bit', 'WindowsPE') ('Windows', '10', '10.0.19043') Python 3.10.1 Windows: ('10', '10.0.19043', 'SP0', 'Multiprocessor Free') Interface language: None Successfully initialized third party plugins: ACSM Input (0, 0, 17) && DeDRM (10, 0, 3) && ACSM Input Plugin GUI Extension (0, 0, 17) && Find Duplicates (1, 10, 1) && KindleUnpack - The Plugin (0, 83, 1) Traceback (most recent call last): File "calibre\customize\ui.py", line 676, in initialize_plugin File "calibre_plugins.deacsm.init", line 164, in initialize File "calibre_plugins.deacsm.init", line 114, in init_embedded_plugins ImportError: cannot import name 'ACSMInputGUIExtension' from 'calibre_plugins.deacsm.gui_main_wrapper' (C:\Users\XYZ\AppData\Roaming\calibre\plugins\ACSM Input.zip/gui_main_wrapper.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "calibre\gui2\preferences\plugins.py", line 325, in add_plugin File "calibre\customize\ui.py", line 486, in add_plugin File "calibre\customize\ui.py", line 681, in initialize_plugin calibre.customize.InvalidPlugin: Initialization of plugin Traceback (most recent call last): File "calibre\customize\ui.py", line 676, in initialize_plugin File "calibre_plugins.deacsm.init", line 164, in initialize File "calibre_plugins.deacsm.init", line 114, in init_embedded_plugins ImportError: cannot import name 'ACSMInputGUIExtension' from 'calibre_plugins.deacsm.gui_main_wrapper' (C:\Users\XYZ\AppData\Roaming\calibre\plugins\ACSM Input.zip/gui_main_wrapper.py) failed with traceback: Traceback (most recent call last): File "calibre\customize\ui.py", line 676, in initialize_plugin File "calibre_plugins.deacsm.init", line 164, in initialize File "calibre_plugins.deacsm.init", line 114, in init_embedded_plugins ImportError: cannot import name 'ACSMInputGUIExtension' from 'calibre_plugins.deacsm.gui_main_wrapper' (C:\Users\XYZ\AppData\Roaming\calibre\plugins\ACSM Input.zip/gui_main_wrapper.py)`

Got this error when trying to load the calibre-plugin.zip inside the calibre-plugins.zip

Leseratte10 commented 1 year ago

Interesting. Are you updating from 0.0.16 or from a previous beta? Can you try uninstalling the current version then installing this one?

p1nkyy commented 1 year ago

Interesting. Are you updating from 0.0.16 or from a previous beta? Can you try uninstalling the current version then installing this one?

This is one of your beta that solves the return issue. OK I will uninstall this one then. Should I also uninstall the interface plugin?

Leseratte10 commented 1 year ago

Nope, that will auto-uninstall itself when uninstalling the main plugin. Just uninstall, restart Calibre, then try to install the new version and see if that works.

p1nkyy commented 1 year ago

OK, uninstalling the old one and then re-installing a newer one works. My loaned list got cleared up of course but I guess it's OK.

Leseratte10 commented 1 year ago

I still wonder why that happens, though; I haven't been able to reproduce that ...

p1nkyy commented 1 year ago

The queuing system implemented sometimes caused 1-2 ACSMs in a batch to be failed to be processed and needed to be re-added.