mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 19:44:15 +02:00
Fix: app crashes when no internet connection
This commit is contained in:
@@ -67,6 +67,7 @@ class ApplicationManager(ABC):
|
||||
def cache_to_disk(self, app: Application, icon_bytes: bytes, only_icon: bool):
|
||||
pass
|
||||
|
||||
|
||||
from fpakman.core.worker import FlatpakAsyncDataLoaderManager
|
||||
|
||||
|
||||
@@ -173,6 +174,7 @@ class FlatpakManager(ApplicationManager):
|
||||
def downgrade_app(self, app: FlatpakApplication, root_password: str):
|
||||
|
||||
commits = flatpak.get_app_commits(app.ref, app.origin)
|
||||
|
||||
commit_idx = commits.index(app.commit)
|
||||
|
||||
# downgrade is not possible if the app current commit in the first one:
|
||||
|
||||
3
fpakman/core/exception.py
Normal file
3
fpakman/core/exception.py
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
class NoInternetException(Exception):
|
||||
pass
|
||||
@@ -3,6 +3,7 @@ import subprocess
|
||||
from typing import List
|
||||
|
||||
from fpakman.core import system
|
||||
from fpakman.core.exception import NoInternetException
|
||||
from fpakman.core.model import Application
|
||||
|
||||
BASE_CMD = 'flatpak'
|
||||
@@ -128,12 +129,19 @@ def downgrade_and_stream(app_ref: str, commit: str, root_password: str):
|
||||
|
||||
def get_app_commits(app_ref: str, origin: str) -> List[str]:
|
||||
log = system.run_cmd('{} remote-info --log {} {}'.format(BASE_CMD, origin, app_ref))
|
||||
return re.findall(r'Commit+:\s(.+)', log)
|
||||
|
||||
if log:
|
||||
return re.findall(r'Commit+:\s(.+)', log)
|
||||
else:
|
||||
raise NoInternetException()
|
||||
|
||||
|
||||
def get_app_commits_data(app_ref: str, origin: str) -> List[dict]:
|
||||
log = system.run_cmd('{} remote-info --log {} {}'.format(BASE_CMD, origin, app_ref))
|
||||
|
||||
if not log:
|
||||
raise NoInternetException()
|
||||
|
||||
res = re.findall(r'(Commit|Subject|Date):\s(.+)', log)
|
||||
|
||||
commits = []
|
||||
|
||||
Reference in New Issue
Block a user