WebThingsIO / gateway

WebThings Gateway
http://webthings.io/gateway
Mozilla Public License 2.0
2.61k stars 337 forks source link

Remove persistent data and settings when add-on is uninstalled #2565

Open flatsiedatsie opened 4 years ago

flatsiedatsie commented 4 years ago

Currently, when an addon is removed, the persistent data stays put. This can be troublesome if the addon is experiencing an issue that could be solved by removing the persistence file, which a re-install could achieve.

mrstegeman commented 4 years ago

As an easy workaround, you could add a config option to remove the data on next startup, then flip the flag back after you've removed it.

flatsiedatsie commented 4 years ago

Sure, it's something that can be programmed around. An example is when the Voco and Internet Radio addon got a new value to add to the persistence file. I have some code that checks if the value is in the loaded persistence data, and adds a default value if it isn't.

My question is more about the fundamental principle. Should the gateway also delete the addon's persistence files when the addon is deleted? To me it seems the answer is 'yes', but I was wondering if there was a reason why this isn't currently the case that I hadn't thought about.

If this situation isn't a concious choice, then I'd advocate to delete the persistence files:

mrstegeman commented 4 years ago

Yes, the gateway probably should delete persistent data and add-on settings when an add-on is uninstalled. At some point, we decided not to do that for some reason, but I can no longer remember why.

madb1lly commented 4 years ago

Hi all,

@flatsiedatsie is right, that data should be removed, but.... when I'm having difficulties with adapters, e.g. after a non-graceful restart (e.g. after loss of power) I sometimes find that uninstalling then reinstalling an adapter helps fix them, and the fact that they "remember" their previous settings is very helpful otherwise I'd have to reconfigure them, and all the rules that depend on them.

That's the only use-case for the status quo that I can see from my point of view.

Cheers 🙂

flatsiedatsie commented 3 years ago

when I'm having difficulties with adapters, e.g. after a non-graceful restart (e.g. after loss of power) I sometimes find that uninstalling then reinstalling an adapter helps fix them

But having old config files could just as easily hinder a fresh install.

madb1lly commented 3 years ago

Hi @flatsiedatsie, So how to manage the case where removing and reinstalling with persistent config files does fix the issue? Cheers 🙂

flatsiedatsie commented 3 years ago

I think that of the two cases, the one you describe is less important. With the one I describe you can't use the addon properly again (re-installation doesn't solve it), while the one you describe just means you have to re-do some labor. Both are bad, but I would argue one is worse.

(Looking back, I believe some of my users have experienced this issue. They had to re-install the gateway from scratch to get the addon working again).

madb1lly commented 3 years ago

Well depending on the add-on it's quite a lot of labour! Especially if the associated Things are used in lots of rules.

I get your point though. A option to uninstall and retain data/settings would be nice if the default is to remove all data/settings.