Skip to content

Commit

Permalink
Fixed downgrade view
Browse files Browse the repository at this point in the history
  • Loading branch information
anaselli committed Jan 2, 2025
1 parent 932c20c commit 1fe0d63
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions dnfdragora/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,11 @@ def _fillPackageList(self, groupName=None, filter="all") :
self._setStatusToItem(pkg,item)

if filter == 'all' or filter == 'not_installed' or filter == 'skip_other':
installed_pkgs = {}
if self.packageActionValue == const.Actions.DOWNGRADE:
installed = self.backend.get_packages('installed')
installed_pkgs = {p.name:p for p in installed}

available = self.backend.get_packages('available')
for pkg in available :
## NOTE get_groups_from_package calls group caching so we try to avoid it if 'all' is selected
Expand All @@ -896,6 +901,13 @@ def _fillPackageList(self, groupName=None, filter="all") :
else:
groups_pkg = self.backend.get_groups_from_package(pkg)
insert_items = groupName in groups_pkg
# if looking for downgrade we must add only the available that are instaled
# TODO check if they are also updates
if self.packageActionValue == const.Actions.DOWNGRADE:
if pkg.name not in installed_pkgs:
insert_items = False
elif pkg.fullname >= installed_pkgs[pkg.name].fullname:
insert_items = False

if insert_items :
skip_insert = (filter == 'skip_other' and not (pkg.arch == 'noarch' or pkg.arch == platform.machine()))
Expand Down Expand Up @@ -1371,10 +1383,10 @@ def _populate_transaction(self) :
logger.debug('Reinstalling %s' %(pkgs))
self.backend.Reinstall(pkgs, sync=True)
elif self.packageActionValue == const.Actions.DOWNGRADE:
pkg_ids = self.packageQueue.get('r')
pkg_ids = self.packageQueue.get('i')
if len(pkg_ids) >0:
pkgs = [dnfdragora.misc.pkg_id_to_full_nevra(pkg_id) for pkg_id in pkg_ids]
logger.debug('Reinstalling %s' %(pkgs))
logger.debug('Downgrading %s' %(pkgs))
self.backend.Downgrade(pkgs, sync=True)
elif self.packageActionValue == const.Actions.DISTRO_SYNC:
pkg_ids = self.packageQueue.get('r')
Expand Down Expand Up @@ -1531,7 +1543,8 @@ def _updateActionView(self, newAction):
if platform.machine() == "x86_64" :
ordered_filters.append('skip_other')
elif newAction == const.Actions.DOWNGRADE:
ordered_filters = [ 'installed' ]
ordered_filters = [ 'not_installed' ]
filter_item = 'not_installed'
apply_button_text = _("&Downgrade")
elif newAction == const.Actions.REINSTALL:
ordered_filters = [ 'installed' ]
Expand Down

0 comments on commit 1fe0d63

Please sign in to comment.