def downgrade(self, pkg: FlatpakApplication, root_password: str, watcher: ProcessWatcher) -> bool: handler = ProcessHandler(watcher) pkg.commit = flatpak.get_commit(pkg.id, pkg.branch, pkg.installation) watcher.change_progress(10) watcher.change_substatus(self.i18n['flatpak.downgrade.commits']) commits = flatpak.get_app_commits(pkg.ref, pkg.origin, pkg.installation, handler) if commits is None: return False commit_idx = commits.index(pkg.commit) # downgrade is not possible if the app current commit in the first one: if commit_idx == len(commits) - 1: watcher.show_message( self.i18n['flatpak.downgrade.impossible.title'], self.i18n['flatpak.downgrade.impossible.body'], MessageType.WARNING) return False commit = commits[commit_idx + 1] watcher.change_substatus(self.i18n['flatpak.downgrade.reverting']) watcher.change_progress(50) success = handler.handle( SystemProcess( subproc=flatpak.downgrade(pkg.ref, commit, pkg.installation, root_password), success_phrases=['Changes complete.', 'Updates complete.'], wrong_error_phrase='Warning')) watcher.change_progress(100) return success
def get_history(self, pkg: FlatpakApplication, full_commit_str: bool = False) -> PackageHistory: pkg.commit = flatpak.get_commit(pkg.id, pkg.branch, pkg.installation) pkg_commit = pkg.commit if pkg.commit else None if pkg_commit and not full_commit_str: pkg_commit = pkg_commit[0:8] commits = flatpak.get_app_commits_data(pkg.ref, pkg.origin, pkg.installation, full_str=full_commit_str) status_idx = 0 commit_found = False if pkg_commit is None and len(commits) > 1 and commits[0]['commit'] == '(null)': del commits[0] pkg_commit = commits[0] commit_found = True if not commit_found: 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 get_history(self, pkg: FlatpakApplication) -> PackageHistory: pkg.commit = flatpak.get_commit(pkg.id, pkg.branch) commits = flatpak.get_app_commits_data(pkg.ref, pkg.origin) status_idx = 0 for idx, data in enumerate(commits): if data['commit'] == pkg.commit: status_idx = idx break return PackageHistory(pkg=pkg, history=commits, pkg_status_idx=status_idx)