manatools / dnfdaemon

DBus daemon for doing package action with the dnf package manager
GNU General Public License v2.0
12 stars 16 forks source link

Plugins not loaded after first daemon access #36

Open LaurieReeves opened 4 years ago

LaurieReeves commented 4 years ago

Well, this is embarrassing.

There is a small issue with the recent pull-request that I submitted (https://github.com/manatools/dnfdaemon/commit/ec3cbde0e7568622748f9225870f2b7c8d1bac9b) (which was merged, thank you!).

The first time the daemon is accessed everything works. Plugins are loaded, variables in repo urls are populated, everything's good. If the daemon is accessed a second time, plugins are not loaded, variables are not substituted. When I enable debug logging, I can see that the plugins fail to load: "Failed to init plugins: load_plugins() called twice".

In dnfdaemon, the dnf.Base object is "reset" after a transaction and it looks like that is not compatible with plugins. However, I do see that the reset is necessary to get updated state. e.g. if you install a package the current dnf.Base thinks the package is not installed.

As per the dnf documentation, it is assumed that the dnf.Base object lives for the length of the program's life and there is further implication that plugins get a reference to this Base object:

https://dnf.readthedocs.io/en/latest/api_base.html

For now, I can force the daemon to exit before every transaction, but this is not ideal. I fear a more formal solution would require a bit of a refactoring, but hopefully there's a simple fix.