[fix][flatpak] not retrieving the history correctly for different instalation levels

This commit is contained in:
Vinícius Moreira
2020-01-13 18:55:25 -03:00
parent bbb5aa92bb
commit 3aa5c16f8d
2 changed files with 10 additions and 11 deletions

View File

@@ -151,7 +151,7 @@ class FlatpakManager(SoftwareManager):
return SearchResult(models, None, len(models)) return SearchResult(models, None, len(models))
def downgrade(self, pkg: FlatpakApplication, root_password: str, watcher: ProcessWatcher) -> bool: def downgrade(self, pkg: FlatpakApplication, root_password: str, watcher: ProcessWatcher) -> bool:
pkg.commit = flatpak.get_commit(pkg.id, pkg.branch) pkg.commit = flatpak.get_commit(pkg.id, pkg.branch, pkg.installation)
watcher.change_progress(10) watcher.change_progress(10)
watcher.change_substatus(self.i18n['flatpak.downgrade.commits']) watcher.change_substatus(self.i18n['flatpak.downgrade.commits'])
@@ -190,7 +190,7 @@ class FlatpakManager(SoftwareManager):
def get_info(self, app: FlatpakApplication) -> dict: def get_info(self, app: FlatpakApplication) -> dict:
if app.installed: if app.installed:
app_info = flatpak.get_app_info_fields(app.id, app.branch) app_info = flatpak.get_app_info_fields(app.id, app.branch, app.installation)
app_info['name'] = app.name app_info['name'] = app.name
app_info['type'] = 'runtime' if app.runtime else 'app' app_info['type'] = 'runtime' if app.runtime else 'app'
app_info['description'] = strip_html(app.description) if app.description else '' app_info['description'] = strip_html(app.description) if app.description else ''
@@ -230,7 +230,7 @@ class FlatpakManager(SoftwareManager):
return {} return {}
def get_history(self, pkg: FlatpakApplication) -> PackageHistory: def get_history(self, pkg: FlatpakApplication) -> PackageHistory:
pkg.commit = flatpak.get_commit(pkg.id, pkg.branch) pkg.commit = flatpak.get_commit(pkg.id, pkg.branch, pkg.installation)
commits = flatpak.get_app_commits_data(pkg.ref, pkg.origin, pkg.installation) commits = flatpak.get_app_commits_data(pkg.ref, pkg.origin, pkg.installation)
status_idx = 0 status_idx = 0

View File

@@ -2,18 +2,17 @@ import re
import subprocess import subprocess
import traceback import traceback
from datetime import datetime from datetime import datetime
from io import StringIO
from typing import List, Dict, Set from typing import List, Dict, Set
from bauh.api.exception import NoInternetException from bauh.api.exception import NoInternetException
from bauh.commons.system import new_subprocess, run_cmd, new_root_subprocess, SimpleProcess, SystemProcess from bauh.commons.system import new_subprocess, run_cmd, new_root_subprocess, SimpleProcess
BASE_CMD = 'flatpak' BASE_CMD = 'flatpak'
RE_SEVERAL_SPACES = re.compile(r'\s+') RE_SEVERAL_SPACES = re.compile(r'\s+')
def get_app_info_fields(app_id: str, branch: str, fields: List[str] = [], check_runtime: bool = False): def get_app_info_fields(app_id: str, branch: str, installation: str, fields: List[str] = [], check_runtime: bool = False):
info = re.findall(r'\w+:\s.+', get_app_info(app_id, branch)) info = re.findall(r'\w+:\s.+', get_app_info(app_id, branch, installation))
data = {} data = {}
fields_to_retrieve = len(fields) + (1 if check_runtime and 'ref' not in fields else 0) fields_to_retrieve = len(fields) + (1 if check_runtime and 'ref' not in fields else 0)
@@ -63,12 +62,12 @@ def get_version():
return res.split(' ')[1].strip() if res else None return res.split(' ')[1].strip() if res else None
def get_app_info(app_id: str, branch: str): def get_app_info(app_id: str, branch: str, installation: str):
return run_cmd('{} info {} {}'.format(BASE_CMD, app_id, branch)) return run_cmd('{} info {} {}'.format(BASE_CMD, app_id, branch, '--{}'.format(installation)))
def get_commit(app_id: str, branch: str) -> str: def get_commit(app_id: str, branch: str, installation: str) -> str:
info = new_subprocess([BASE_CMD, 'info', app_id, branch]) info = new_subprocess([BASE_CMD, 'info', app_id, branch, '--{}'.format(installation)])
for o in new_subprocess(['grep', 'Commit:', '--color=never'], stdin=info.stdout).stdout: for o in new_subprocess(['grep', 'Commit:', '--color=never'], stdin=info.stdout).stdout:
if o: if o: