Пример #1
0
    def downgrade(self, pkg: FlatpakApplication, root_password: str,
                  watcher: ProcessWatcher) -> bool:
        if not self._make_exports_dir(watcher):
            return False

        watcher.change_progress(10)
        watcher.change_substatus(self.i18n['flatpak.downgrade.commits'])

        history = self.get_history(pkg, full_commit_str=True)

        # downgrade is not possible if the app current commit in the first one:
        if history.pkg_status_idx == len(history.history) - 1:
            watcher.show_message(
                self.i18n['flatpak.downgrade.impossible.title'],
                self.i18n['flatpak.downgrade.impossible.body'].format(
                    bold(pkg.name)), MessageType.ERROR)
            return False

        commit = history.history[history.pkg_status_idx + 1]['commit']
        watcher.change_substatus(self.i18n['flatpak.downgrade.reverting'])
        watcher.change_progress(50)
        success, _ = ProcessHandler(watcher).handle_simple(
            flatpak.downgrade(pkg.ref, commit, pkg.installation,
                              root_password))
        watcher.change_progress(100)
        return success
Пример #2
0
    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