02-01-2011, 03:28 PM | #1 |
Sigil developer
Posts: 1,275
Karma: 1101600
Join Date: Jan 2011
Location: UK
Device: Kindle PW, K4 NT, K3, Kobo Touch
|
Removal of plugin not removing config store
It appears that when you remove a plugin it doesn't remove the configuration store information.
In my plugin I run plugin_store = JSONConfig('plugins/somename') and c = config_store().get(storename, storedefaults) along with c.get and c.set. Data saves and loads ok. However, if I remove the plugin either by the GUI or cli, when I re-add my plugin and start it, the last values saved in the store are visible to the plugin. Because I stored some incorrect data one time, this caused some problems in plugin development. Although I was able to get around it by saving an empty data set to the store before continuing. I expected the plugin removal to remove any stored information for the plugin. Is it leaving the information just in case, or is it a bug? Is there a way to manually remove the store (in order to give instructions for a complete removal)? |
02-01-2011, 03:34 PM | #2 |
creator of calibre
Posts: 43,776
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Since plugins can execute arbitrary code, there is no way to reliably remove their stored config information. You should add error handlers in your plugin to deal with malformed persistent data.
|
02-01-2011, 03:42 PM | #3 |
Sigil developer
Posts: 1,275
Karma: 1101600
Join Date: Jan 2011
Location: UK
Device: Kindle PW, K4 NT, K3, Kobo Touch
|
Okay, thanks. I was thinking of adding a version number to the store as well, but it still needs to handle errors. Though I may ending up having to save to an external file anyway to allow some more flexibility in what I'm doing.
By the way for Calibre! Its proving not only great to use but also great to develop with |
02-01-2011, 04:34 PM | #4 |
creator of calibre
Posts: 43,776
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Cool. my development goal with calibre is to try and always optimize for maintainability.
|
02-01-2011, 04:45 PM | #5 |
calibre/Sigil Developer
Posts: 4,601
Karma: 2092290
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
|
I had been wondering about asking Kovid if he would be interested in offering an optional "def uninstall(self)" function or similar as part of the plugin API, giving plugins an opportunity to implement their own cleanup. As he said above there is no way Calibre can "automatically" do anything as we have such freedom to do what we like within a plugin... mwah hah haaa...
Why I hadn't as yet at least asked was that it is possible that users seeing a new version of a plugin erroneously think that they need to uninstall the old one first. That would of course make them lose all their settings. Either way the issue can be resolved if with sufficient documentation if the users will read it - such as telling them to go to the config plugins directory and delete the .JSON file if it bothers them. |
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
DRM removal plugin for Calibre | cococrou | Plugins | 63 | 11-01-2012 05:08 PM |
Create area for plugin images in config directory | DoctorOhh | Plugins | 19 | 12-15-2010 12:28 PM |
New Plugin Type Idea: Library Plugin | cgranade | Plugins | 3 | 09-15-2010 12:11 PM |
Statusbar config? | tselling | PocketBook | 0 | 11-13-2009 10:47 AM |
Removing DRM from Sony Store books | thibaulthalpern | Sony Reader | 10 | 03-11-2009 01:17 AM |