mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-10 11:04:15 +02:00
[improvement][ui] not performing a full table refresh after installing a new package
This commit is contained in:
@@ -7,7 +7,7 @@ from threading import Thread
|
||||
from typing import List, Set, Type, Tuple, Dict
|
||||
|
||||
from bauh.api.abstract.controller import SoftwareManager, SearchResult, ApplicationContext, UpgradeRequirements, \
|
||||
UpgradeRequirement
|
||||
UpgradeRequirement, TransactionResult
|
||||
from bauh.api.abstract.disk import DiskCacheLoader
|
||||
from bauh.api.abstract.handler import ProcessWatcher, TaskManager
|
||||
from bauh.api.abstract.model import SoftwarePackage, PackageUpdate, PackageHistory, PackageSuggestion, \
|
||||
@@ -291,18 +291,22 @@ class GenericSoftwareManager(SoftwareManager):
|
||||
if man:
|
||||
return man.uninstall(app, root_password, handler)
|
||||
|
||||
def install(self, app: SoftwarePackage, root_password: str, handler: ProcessWatcher) -> bool:
|
||||
def install(self, app: SoftwarePackage, root_password: str, disk_loader: DiskCacheLoader, handler: ProcessWatcher) -> TransactionResult:
|
||||
man = self._get_manager_for(app)
|
||||
|
||||
if man:
|
||||
ti = time.time()
|
||||
disk_loader = self.disk_loader_factory.new()
|
||||
disk_loader.start()
|
||||
try:
|
||||
self.logger.info('Installing {}'.format(app))
|
||||
return man.install(app, root_password, handler)
|
||||
return man.install(app, root_password, disk_loader, handler)
|
||||
except:
|
||||
traceback.print_exc()
|
||||
return False
|
||||
return TransactionResult(success=False, installed=[], removed=[])
|
||||
finally:
|
||||
disk_loader.stop_working()
|
||||
disk_loader.join()
|
||||
tf = time.time()
|
||||
self.logger.info('Installation of {}'.format(app) + 'took {0:.2f} minutes'.format((tf - ti)/60))
|
||||
|
||||
|
||||
@@ -631,17 +631,20 @@ class InstallPackage(AsyncAction):
|
||||
|
||||
def run(self):
|
||||
if self.pkg:
|
||||
success = False
|
||||
res = {'success': False, 'installed': None, 'removed': None, 'pkg': self.pkg}
|
||||
|
||||
if self.pkg.model.supports_backup():
|
||||
if not self.request_backup(read_config(), 'install', self.i18n, self.root_pwd):
|
||||
self.signal_finished.emit({'success': False, 'pkg': self.pkg})
|
||||
self.signal_finished.emit(res)
|
||||
return
|
||||
|
||||
try:
|
||||
success = self.manager.install(self.pkg.model, self.root_pwd, self)
|
||||
transaction_res = self.manager.install(self.pkg.model, self.root_pwd, None, self)
|
||||
res['success'] = transaction_res.success
|
||||
res['installed'] = transaction_res.installed
|
||||
res['removed'] = transaction_res.removed
|
||||
|
||||
if success:
|
||||
if transaction_res.success:
|
||||
self.pkg.model.installed = True
|
||||
|
||||
if self.pkg.model.supports_disk_cache():
|
||||
@@ -650,10 +653,10 @@ class InstallPackage(AsyncAction):
|
||||
icon_bytes=icon_data.get('bytes') if icon_data else None,
|
||||
only_icon=False)
|
||||
except (requests.exceptions.ConnectionError, NoInternetException):
|
||||
success = False
|
||||
res['success'] = False
|
||||
self.print(self.i18n['internet.required'])
|
||||
finally:
|
||||
self.signal_finished.emit({'success': success, 'pkg': self.pkg})
|
||||
self.signal_finished.emit(res)
|
||||
self.pkg = None
|
||||
|
||||
|
||||
|
||||
@@ -1211,7 +1211,23 @@ class ManageWindow(QWidget):
|
||||
if self._can_notify_user():
|
||||
util.notify_user(msg='{} ({}) {}'.format(res['pkg'].model.name, res['pkg'].model.get_type(), self.i18n['installed']))
|
||||
|
||||
self._finish_refresh_apps({'installed': [res['pkg'].model], 'total': 1, 'types': None})
|
||||
models_updated = []
|
||||
|
||||
for key in ('installed', 'removed'):
|
||||
if res.get(key):
|
||||
models_updated.extend(res[key])
|
||||
|
||||
if models_updated:
|
||||
view_to_update = []
|
||||
for displayed in self.pkgs:
|
||||
for p in models_updated:
|
||||
if displayed.model == p:
|
||||
displayed.model = p
|
||||
view_to_update.append(displayed)
|
||||
|
||||
for pkgv in view_to_update:
|
||||
self.table_apps.update_package(pkgv)
|
||||
|
||||
self.ref_bt_installed.setVisible(False)
|
||||
self.ref_checkbox_only_apps.setVisible(False)
|
||||
self.update_custom_actions()
|
||||
@@ -1324,3 +1340,4 @@ class ManageWindow(QWidget):
|
||||
body=self.i18n['action.{}.fail'.format(res['action'])].format(bold(res['pkg'].model.name)),
|
||||
type_=MessageType.ERROR)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user