[flatpak] fix -> downgrading crashing with version 1.8.X | history: the top commit is returned as '(null)'

This commit is contained in:
Vinicius Moreira
2020-08-11 11:21:05 -03:00
parent 57c88f9589
commit 444dca5641
2 changed files with 16 additions and 1 deletions

View File

@@ -180,7 +180,13 @@ class FlatpakManager(SoftwareManager):
if commits is None:
return False
commit_idx = commits.index(pkg.commit)
try:
commit_idx = commits.index(pkg.commit)
except ValueError:
if commits[0] == '(null)':
commit_idx = 0
else:
return False
# downgrade is not possible if the app current commit in the first one:
if commit_idx == len(commits) - 1:
@@ -301,13 +307,19 @@ class FlatpakManager(SoftwareManager):
def get_history(self, pkg: FlatpakApplication) -> PackageHistory:
pkg.commit = flatpak.get_commit(pkg.id, pkg.branch, pkg.installation)
commits = flatpak.get_app_commits_data(pkg.ref, pkg.origin, pkg.installation)
status_idx = 0
commit_found = False
for idx, data in enumerate(commits):
if data['commit'] == pkg.commit:
status_idx = idx
commit_found = True
break
if not commit_found and pkg.commit and commits[0]['commit'] == '(null)':
commits[0]['commit'] = pkg.commit
return PackageHistory(pkg=pkg, history=commits, pkg_status_idx=status_idx)
def _make_exports_dir(self, watcher: ProcessWatcher) -> bool: