From 17b5a482548f7d628830f1026bb57dd1fcb0007f Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Tue, 10 May 2022 18:39:35 -0300 Subject: [PATCH] [flatpak] fix: not all selected runtime partials to upgrade are actually requested to be upgraded --- CHANGELOG.md | 5 +++++ bauh/gems/flatpak/controller.py | 30 +++++++++++------------------- bauh/gems/flatpak/model.py | 11 ++++++++++- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1aa1f40b..fdf91701 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - manage window minimum width related to the table columns - table columns width for maximized window + +### Fixes +- Flatpak + - not all selected runtime partials to upgrade are actually requested to be upgraded + ## [0.10.2] 2022-04-16 ### Improvements - Arch diff --git a/bauh/gems/flatpak/controller.py b/bauh/gems/flatpak/controller.py index bcfc76d6..14df2468 100644 --- a/bauh/gems/flatpak/controller.py +++ b/bauh/gems/flatpak/controller.py @@ -3,6 +3,7 @@ import re import traceback from datetime import datetime from math import floor +from operator import attrgetter from pathlib import Path from threading import Thread from typing import List, Set, Type, Tuple, Optional, Generator, Dict @@ -707,31 +708,22 @@ class FlatpakManager(SoftwareManager, SettingsController): return UpgradeRequirements(None, None, to_update, []) def sort_update_order(self, pkgs: List[FlatpakApplication]) -> List[FlatpakApplication]: - partials, runtimes, apps = [], [], [] + runtimes, apps = set(), set() for p in pkgs: if p.runtime: - if p.partial: - partials.append(p) - else: - runtimes.append(p) + runtimes.add(p) else: - apps.append(p) + apps.add(p) - if not runtimes: - return [*partials, *apps] - elif partials: - all_runtimes = [] - for runtime in runtimes: - for partial in partials: - if partial.installation == runtime.installation and partial.base_id == runtime.id: - all_runtimes.append(partial) - break + sorted_list = [] + for comps in (runtimes, apps): + if comps: + comp_list = list(comps) + comp_list.sort(key=attrgetter('installation', 'name')) + sorted_list.extend(comp_list) - all_runtimes.append(runtime) - return [*all_runtimes, *apps] - else: - return [*runtimes, *apps] + return sorted_list def _read_ignored_updates(self) -> Set[str]: ignored = set() diff --git a/bauh/gems/flatpak/model.py b/bauh/gems/flatpak/model.py index 9b71a2f5..e2bac51e 100644 --- a/bauh/gems/flatpak/model.py +++ b/bauh/gems/flatpak/model.py @@ -125,7 +125,16 @@ class FlatpakApplication(SoftwarePackage): def __eq__(self, other): if isinstance(other, FlatpakApplication): - return self.id == other.id and self.installation == other.installation and self.branch == other.branch + return self.id == other.id and self.installation == other.installation and self.branch == other.branch \ + and self.runtime == other.runtime and self.partial == other.partial and \ + self.update_component == other.update_component + + def __hash__(self) -> int: + hash_sum = 0 + for attr in ('id', 'installation', 'branch', 'runtime', 'partial', 'update_component'): + hash_sum += hash(getattr(self, attr)) + + return hash_sum def get_disk_icon_path(self) -> str: if not self.runtime: