mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-08 16:44:16 +02:00
[flatpak] improvement -> Creating the exports path '~/.local/share/flatpak/exports/share' (if it does not exist) and adding it to install/upgrade/downgrade/remove commands path to prevent warning messages
This commit is contained in:
@@ -18,7 +18,7 @@ from bauh.commons import user, internet
|
||||
from bauh.commons.config import save_config
|
||||
from bauh.commons.html import strip_html, bold
|
||||
from bauh.commons.system import SystemProcess, ProcessHandler
|
||||
from bauh.gems.flatpak import flatpak, SUGGESTIONS_FILE, CONFIG_FILE, UPDATES_IGNORED_FILE, CONFIG_DIR
|
||||
from bauh.gems.flatpak import flatpak, SUGGESTIONS_FILE, CONFIG_FILE, UPDATES_IGNORED_FILE, CONFIG_DIR, EXPORTS_PATH
|
||||
from bauh.gems.flatpak.config import read_config
|
||||
from bauh.gems.flatpak.constants import FLATHUB_API_URL
|
||||
from bauh.gems.flatpak.model import FlatpakApplication
|
||||
@@ -166,6 +166,10 @@ class FlatpakManager(SoftwareManager):
|
||||
return SearchResult(models, None, len(models))
|
||||
|
||||
def downgrade(self, pkg: FlatpakApplication, root_password: str, watcher: ProcessWatcher) -> bool:
|
||||
|
||||
if not self._make_exports_dir(watcher):
|
||||
return False
|
||||
|
||||
handler = ProcessHandler(watcher)
|
||||
pkg.commit = flatpak.get_commit(pkg.id, pkg.branch, pkg.installation)
|
||||
|
||||
@@ -198,6 +202,10 @@ class FlatpakManager(SoftwareManager):
|
||||
|
||||
def upgrade(self, requirements: UpgradeRequirements, root_password: str, watcher: ProcessWatcher) -> bool:
|
||||
flatpak_version = flatpak.get_version()
|
||||
|
||||
if not self._make_exports_dir(watcher):
|
||||
return False
|
||||
|
||||
for req in requirements.to_upgrade:
|
||||
watcher.change_status("{} {} ({})...".format(self.i18n['manage_window.status.upgrading'], req.pkg.name, req.pkg.version))
|
||||
related, deps = False, False
|
||||
@@ -227,6 +235,10 @@ class FlatpakManager(SoftwareManager):
|
||||
return True
|
||||
|
||||
def uninstall(self, pkg: FlatpakApplication, root_password: str, watcher: ProcessWatcher, disk_loader: DiskCacheLoader) -> TransactionResult:
|
||||
|
||||
if not self._make_exports_dir(watcher):
|
||||
return TransactionResult.fail()
|
||||
|
||||
uninstalled = ProcessHandler(watcher).handle(SystemProcess(subproc=flatpak.uninstall(pkg.ref, pkg.installation)))
|
||||
|
||||
if uninstalled:
|
||||
@@ -298,6 +310,18 @@ class FlatpakManager(SoftwareManager):
|
||||
|
||||
return PackageHistory(pkg=pkg, history=commits, pkg_status_idx=status_idx)
|
||||
|
||||
def _make_exports_dir(self, watcher: ProcessWatcher) -> bool:
|
||||
if not os.path.exists(EXPORTS_PATH):
|
||||
self.logger.info("Creating dir '{}'".format(EXPORTS_PATH))
|
||||
watcher.print('Creating dir {}'.format(EXPORTS_PATH))
|
||||
try:
|
||||
os.mkdir(EXPORTS_PATH)
|
||||
except:
|
||||
watcher.print('Error while creating the directory {}'.format(EXPORTS_PATH))
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def install(self, pkg: FlatpakApplication, root_password: str, disk_loader: DiskCacheLoader, watcher: ProcessWatcher) -> TransactionResult:
|
||||
config = read_config()
|
||||
|
||||
@@ -348,6 +372,9 @@ class FlatpakManager(SoftwareManager):
|
||||
installed = flatpak.list_installed(flatpak_version)
|
||||
installed_by_level = {'{}:{}:{}'.format(p['id'], p['name'], p['branch']) for p in installed if p['installation'] == pkg.installation} if installed else None
|
||||
|
||||
if not self._make_exports_dir(handler.watcher):
|
||||
return TransactionResult(success=False, installed=[], removed=[])
|
||||
|
||||
res = handler.handle(SystemProcess(subproc=flatpak.install(str(pkg.id), pkg.origin, pkg.installation), wrong_error_phrase='Warning'))
|
||||
|
||||
if res:
|
||||
|
||||
Reference in New Issue
Block a user