View Single Post
Old 11-05-2014, 09:42 AM   #680
kiwidude
Calibre Plugins Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,733
Karma: 2197770
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
@anotherCat - it is pretty clear you are not a developer.

The point of the confirmations are that at the end of the day the library for integrity reasons can only have one action being performed on it at a time. This is a combination of the file system that books are stored in and the actual database that stores your library metadata.

You cant run the risk of having two simultaneous actions taking place that result in a conflict that potentially leaves either in a corrupted state. What if you were renaming the author at the same time as a plugin tries to write a new version of the epub into the folder? The action to move books into a new folder from the authot rename, and the action to write the book file are independent of each other, and depending on whether one completes first (or indeed both try at the same time) you get any number of potential problems happen. Like the new version of the epub gets written to the old (now orphaned) folder for that book. Or the book move fails because the file is in use because it is currently being written to. Or any number of other problems that leave you in a right messy state.

So the simplest solution is to prevent those two conflicting actions from occurring at the same time. And the way this is done is by the mere fact that by forcing the user to click ok on the button, control is not returned to you as a user until the action that the confirmation wants to perform is completed. This guarantees the plugin has exclusive access to your library to do its work without fear of conflicts.

So no the buttons are not "redundant". I do agree that they are something it would be nice to avoid, but I cant guarantee that the user will not do something "dumb" at the same time as the plugin tries to do its ing that results in some nasty errors in calibre. In the case of page counts, what happens if you do a page count, then delete the book before you do the confirmation for instance. Or delete or rename the custom column? There are just too many things that "could" have nasty consequences and potentially resulting in calibre crashes, which noone is happy about a plugin causing.

Sure people could swear black and blue that they would never do any sort of conflicting action (that they know of) but that 1 in x chance that someone does could have such dire consequences it is not worth the risk.

The one proviso I will add is that these plugins were written a long time ago, and calibre has moved on since then. Perhaps Kovid now has other protection available via the code to offer an alternative to the prompts, certainly there was not back then and this was the standard pattern every plugin that manipulated the calibre library in this sort of way followed...
kiwidude is offline   Reply With Quote