From 8db6d2ec83a28e772d6597f6a7486886dd177214 Mon Sep 17 00:00:00 2001 From: Jan Kolarik Date: Wed, 7 Feb 2024 09:35:08 +0000 Subject: [PATCH] Fix unload plugins behavior without filelists For packages originating outside the System repository, we don't populate the `pkg.files` when running without filelists metadata. Use RPM database as a source instead. --- dnf/plugin.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dnf/plugin.py b/dnf/plugin.py index d2f46ce340..68cd33422d 100644 --- a/dnf/plugin.py +++ b/dnf/plugin.py @@ -29,6 +29,7 @@ import logging import operator import os +import rpm import sys import traceback @@ -193,13 +194,18 @@ def unload_removed_plugins(self, transaction): # check whether removed plugin file is added at the same time (upgrade of a plugin) for pkg in transaction.install_set: - erased_plugin_files.difference_update(pkg.files) + erased_plugin_files.difference_update(_get_files_from_newly_installed_pkg(pkg)) # unload plugins that were removed in transaction for plugin_file in erased_plugin_files: self.plugins.remove(plugins[plugin_file]) +def _get_files_from_newly_installed_pkg(pkg): + hdr = dnf.util.first(pkg.base._ts.dbMatch('name', pkg.name)) + return hdr[rpm.RPMTAG_FILENAMES] if hdr else [] + + def _plugin_classes(): return Plugin.__subclasses__()