[arch] feature -> AUR: new custom action to quickly reinstall a package

This commit is contained in:
Vinicius Moreira
2021-01-13 15:28:19 -03:00
parent b451d00aaf
commit 5fd161888a
15 changed files with 227 additions and 18 deletions

View File

@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [0.9.12] 2021 ## [0.9.12] 2021
### Features
- Arch
- AUR: new custom action to quickly reinstall a package
<p align="center">
<img src="https://raw.githubusercontent.com/vinifmor/bauh-files/master/pictures/releases/0.9.12/aur_reinstall.png">
</p>
### Improvements ### Improvements
- Arch - Arch
- repositories/AUR search time (=~ -70%) - repositories/AUR search time (=~ -70%)

View File

@@ -41,3 +41,7 @@ class DiskCacheLoaderFactory(ABC):
:return: :return:
""" """
pass pass
@abstractmethod
def new(self) -> DiskCacheLoader:
pass

View File

@@ -26,6 +26,7 @@ from bauh.api.abstract.view import MessageType, FormComponent, InputOption, Sing
ViewComponent, PanelComponent, MultipleSelectComponent, TextInputComponent, TextInputType, \ ViewComponent, PanelComponent, MultipleSelectComponent, TextInputComponent, TextInputType, \
FileChooserComponent, TextComponent FileChooserComponent, TextComponent
from bauh.api.constants import TEMP_DIR from bauh.api.constants import TEMP_DIR
from bauh.api.exception import NoInternetException
from bauh.commons import user, system from bauh.commons import user, system
from bauh.commons.boot import CreateConfigFile from bauh.commons.boot import CreateConfigFile
from bauh.commons.category import CategoriesDownloader from bauh.commons.category import CategoriesDownloader
@@ -3398,3 +3399,32 @@ class ArchManager(SoftwareManager):
continue continue
return res return res
def reinstall(self, pkg: ArchPackage, root_password: str, watcher: ProcessWatcher) -> bool: # only available for AUR packages
if not self.context.internet_checker.is_available():
raise NoInternetException()
self.aur_client.clean_caches()
apidatas = self.aur_client.get_info({pkg.name})
if not apidatas:
watcher.show_message(title=self.i18n['error'],
body=self.i18n['arch.action.reinstall.error.no_apidata'],
type_=MessageType.ERROR)
return False
self.aur_mapper.fill_last_modified(pkg, apidatas[0])
context = TransactionContext.gen_context_from(pkg=pkg,
arch_config=self.configman.get_config(),
root_password=root_password,
handler=ProcessHandler(watcher),
aur_supported=True)
context.skip_opt_deps = False
context.update_aur_index = True
return self.install(pkg=pkg,
root_password=root_password,
watcher=watcher,
context=context,
disk_loader=self.context.disk_loader_factory.new()).success

View File

@@ -7,19 +7,26 @@ from bauh.view.util.translation import I18n
CACHED_ATTRS = {'command', 'icon_path', 'repository', 'maintainer', 'desktop_entry', 'categories', 'last_modified', 'commit'} CACHED_ATTRS = {'command', 'icon_path', 'repository', 'maintainer', 'desktop_entry', 'categories', 'last_modified', 'commit'}
ACTIONS_AUR_ENABLE_PKGBUILD_EDITION = [CustomSoftwareAction(i18n_label_key='arch.action.enable_pkgbuild_edition', ACTION_AUR_ENABLE_PKGBUILD_EDITION = CustomSoftwareAction(i18n_label_key='arch.action.enable_pkgbuild_edition',
i18n_status_key='arch.action.enable_pkgbuild_edition.status', i18n_status_key='arch.action.enable_pkgbuild_edition.status',
i18n_confirm_key='arch.action.enable_pkgbuild_edition.confirm', i18n_confirm_key='arch.action.enable_pkgbuild_edition.confirm',
requires_root=False, requires_root=False,
manager_method='enable_pkgbuild_edition', manager_method='enable_pkgbuild_edition',
icon_path=resource.get_path('img/mark_pkgbuild.svg', ROOT_DIR))] icon_path=resource.get_path('img/mark_pkgbuild.svg', ROOT_DIR))
ACTIONS_AUR_DISABLE_PKGBUILD_EDITION = [CustomSoftwareAction(i18n_label_key='arch.action.disable_pkgbuild_edition', ACTION_AUR_DISABLE_PKGBUILD_EDITION = CustomSoftwareAction(i18n_label_key='arch.action.disable_pkgbuild_edition',
i18n_status_key='arch.action.disable_pkgbuild_edition', i18n_status_key='arch.action.disable_pkgbuild_edition',
i18n_confirm_key='arch.action.disable_pkgbuild_edition.confirm', i18n_confirm_key='arch.action.disable_pkgbuild_edition.confirm',
requires_root=False, requires_root=False,
manager_method='disable_pkgbuild_edition', manager_method='disable_pkgbuild_edition',
icon_path=resource.get_path('img/unmark_pkgbuild.svg', ROOT_DIR))] icon_path=resource.get_path('img/unmark_pkgbuild.svg', ROOT_DIR))
ACTION_AUR_REINSTALL = CustomSoftwareAction(i18n_label_key='arch.action.reinstall',
i18n_status_key='arch.action.reinstall.status',
i18n_confirm_key='arch.action.reinstall.confirm',
requires_root=True,
manager_method='reinstall',
icon_path=resource.get_path('img/build.svg', ROOT_DIR))
class ArchPackage(SoftwarePackage): class ArchPackage(SoftwarePackage):
@@ -174,11 +181,13 @@ class ArchPackage(SoftwarePackage):
return '{}/PKGBUILD'.format(self.get_disk_cache_path()) return '{}/PKGBUILD'.format(self.get_disk_cache_path())
def get_custom_supported_actions(self) -> List[CustomSoftwareAction]: def get_custom_supported_actions(self) -> List[CustomSoftwareAction]:
if self.installed and self.pkgbuild_editable is not None and self.repository == 'aur': if self.installed and self.repository == 'aur':
if self.pkgbuild_editable: actions = [ACTION_AUR_REINSTALL]
return ACTIONS_AUR_DISABLE_PKGBUILD_EDITION
else: if self.pkgbuild_editable is not None:
return ACTIONS_AUR_ENABLE_PKGBUILD_EDITION actions.append(ACTION_AUR_DISABLE_PKGBUILD_EDITION if self.pkgbuild_editable else ACTION_AUR_ENABLE_PKGBUILD_EDITION)
return actions
def __hash__(self): def __hash__(self):
if self.view_name is not None: if self.view_name is not None:

View File

@@ -0,0 +1,119 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="Capa_1"
x="0px"
y="0px"
viewBox="0 0 512 512"
xml:space="preserve"
sodipodi:docname="build.svg"
width="512"
height="512"
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"><metadata
id="metadata947"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs945">
</defs><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1366"
inkscape:window-height="739"
id="namedview943"
showgrid="false"
inkscape:zoom="1.2142857"
inkscape:cx="224"
inkscape:cy="224"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="Capa_1" />
<g
id="g1754"><g
id="g904"
transform="matrix(1.1254561,0,0,1.1254561,3.8978336,3.8978336)"
style="fill:#59a869;fill-opacity:1">
<g
id="g902"
style="fill:#59a869;fill-opacity:1"
transform="matrix(1.4025677,0,0,1.4025677,-90.175165,11.541824)">
<path
d="m 256.272,0 h -64.784 c -4.48,0 -8.752,1.872 -11.712,5.216 C 173.92,11.808 165.472,16 156.032,16 146.592,16 138.128,11.808 132.288,5.216 129.312,1.872 125.04,0 120.56,0 H 72.272 c -4.416,0 -8,3.584 -8,8 v 64 c 0,4.416 3.584,8 8,8 h 48.288 c 4.48,0 8.752,-1.872 11.712,-5.216 C 138.128,68.192 146.576,64 156.032,64 c 32,0 36.256,37.744 36.256,48 l -0.272,64 h 64 v -64 c 0,-28.16 16.56,-48 48.256,-48 32,0 56.976,19.904 70.976,42.72 l 8.48,-4.4 c 0,-0.032 0,-0.032 0,-0.032 C 363.936,44.432 297.136,0 256.272,0 Z m -144,32 h -32 V 16 h 32 z"
id="path900"
style="fill:#59a869;fill-opacity:1" />
</g>
</g><g
id="g1709"><g
id="g1712"><path
d="m 309.83377,357.64138 c 5.05762,-43.91375 1.06571,-60.90544 -18.08097,-97.49327 h -72.25159 c -19.14669,36.58783 -23.13859,53.57952 -18.06291,97.49327 9.12177,78.94169 -0.70444,82.78571 -0.90315,98.31499 -0.19869,15.5293 11.27126,27.0335 25.17969,27.0335 h 59.84239 c 13.90845,0 25.36031,-11.5042 25.17969,-27.0335 -0.19869,-15.52928 -10.02491,-19.3733 -0.90315,-98.31499 z"
id="path906"
style="fill:#59a869;fill-opacity:1;stroke-width:0.99132" /></g></g><g
id="g912">
</g><g
id="g914">
</g><g
id="g916">
</g><g
id="g918">
</g><g
id="g920">
</g><g
id="g922">
</g><g
id="g924">
</g><g
id="g926">
</g><g
id="g928">
</g><g
id="g930">
</g><g
id="g932">
</g><g
id="g934">
</g><g
id="g936">
</g><g
id="g938">
</g><g
id="g940">
</g><rect
style="fill:#59a869;fill-opacity:1;stroke:none;stroke-width:284.117;stroke-miterlimit:4;stroke-dasharray:none"
id="rect1724"
width="90.90567"
height="36.153423"
x="20.398468"
y="37.148106" /></g></svg>

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@@ -9,6 +9,10 @@ arch.action.disable_pkgbuild_edition.status=Unmarking PKGBUILD as editable
arch.action.enable_pkgbuild_edition=Mark PKGBUILD as editable arch.action.enable_pkgbuild_edition=Mark PKGBUILD as editable
arch.action.enable_pkgbuild_edition.confirm=Mark PKGBUILD of {} as editable ? arch.action.enable_pkgbuild_edition.confirm=Mark PKGBUILD of {} as editable ?
arch.action.enable_pkgbuild_edition.status=Marking PKGBUILD as editable arch.action.enable_pkgbuild_edition.status=Marking PKGBUILD as editable
arch.action.reinstall=Reinstall
arch.action.reinstall.status=Reinstalling
arch.action.reinstall.confirm=Do you want to reinstall {} ?
arch.action.reinstall.error.no_apidata=It was not possible to retrieve information of {} from AUR
arch.aur.action.edit_pkgbuild.body=Edit the PKGBUILD file of {} before continuing ? arch.aur.action.edit_pkgbuild.body=Edit the PKGBUILD file of {} before continuing ?
arch.aur.install.pgp.body=Per a instal·lar {} cal rebre les claus PGP següents arch.aur.install.pgp.body=Per a instal·lar {} cal rebre les claus PGP següents
arch.aur.install.pgp.receive_fail=Could not receive PGP key {} arch.aur.install.pgp.receive_fail=Could not receive PGP key {}

View File

@@ -9,6 +9,10 @@ arch.action.disable_pkgbuild_edition.status=Unmarking PKGBUILD as editable
arch.action.enable_pkgbuild_edition=Mark PKGBUILD as editable arch.action.enable_pkgbuild_edition=Mark PKGBUILD as editable
arch.action.enable_pkgbuild_edition.confirm=Mark PKGBUILD of {} as editable ? arch.action.enable_pkgbuild_edition.confirm=Mark PKGBUILD of {} as editable ?
arch.action.enable_pkgbuild_edition.status=Marking PKGBUILD as editable arch.action.enable_pkgbuild_edition.status=Marking PKGBUILD as editable
arch.action.reinstall=Reinstall
arch.action.reinstall.status=Reinstalling
arch.action.reinstall.confirm=Do you want to reinstall {} ?
arch.action.reinstall.error.no_apidata=It was not possible to retrieve information of {} from AUR
arch.aur.action.edit_pkgbuild.body=Edit the PKGBUILD file of {} before continuing ? arch.aur.action.edit_pkgbuild.body=Edit the PKGBUILD file of {} before continuing ?
arch.aur.install.pgp.body=Um {} zu installieren sind folgende PGP Schlüssel nötig arch.aur.install.pgp.body=Um {} zu installieren sind folgende PGP Schlüssel nötig
arch.aur.install.pgp.receive_fail=PGP Schlüssel {} konnte nicht empfangen werden arch.aur.install.pgp.receive_fail=PGP Schlüssel {} konnte nicht empfangen werden

View File

@@ -9,6 +9,10 @@ arch.action.disable_pkgbuild_edition.status=Unmarking PKGBUILD as editable
arch.action.enable_pkgbuild_edition=Mark PKGBUILD as editable arch.action.enable_pkgbuild_edition=Mark PKGBUILD as editable
arch.action.enable_pkgbuild_edition.confirm=Mark PKGBUILD of {} as editable ? arch.action.enable_pkgbuild_edition.confirm=Mark PKGBUILD of {} as editable ?
arch.action.enable_pkgbuild_edition.status=Marking PKGBUILD as editable arch.action.enable_pkgbuild_edition.status=Marking PKGBUILD as editable
arch.action.reinstall=Reinstall
arch.action.reinstall.status=Reinstalling
arch.action.reinstall.confirm=Do you want to reinstall {} ?
arch.action.reinstall.error.no_apidata=It was not possible to retrieve information of {} from AUR
arch.aur.action.edit_pkgbuild.body=Edit the PKGBUILD file of {} before continuing ? arch.aur.action.edit_pkgbuild.body=Edit the PKGBUILD file of {} before continuing ?
arch.aur.install.pgp.body=To install {} is necessary to receive the following PGP keys arch.aur.install.pgp.body=To install {} is necessary to receive the following PGP keys
arch.aur.install.pgp.receive_fail=Could not receive PGP key {} arch.aur.install.pgp.receive_fail=Could not receive PGP key {}

View File

@@ -9,6 +9,10 @@ arch.action.disable_pkgbuild_edition.status=Desmarcando PKGBUILD como editable
arch.action.enable_pkgbuild_edition=Marcar PKGBUILD como editable arch.action.enable_pkgbuild_edition=Marcar PKGBUILD como editable
arch.action.enable_pkgbuild_edition.confirm=Marcar PKGBUILD de {} como editable ? arch.action.enable_pkgbuild_edition.confirm=Marcar PKGBUILD de {} como editable ?
arch.action.enable_pkgbuild_edition.status=Marcando PKGBUILD como editable arch.action.enable_pkgbuild_edition.status=Marcando PKGBUILD como editable
arch.action.reinstall=Reinstalar
arch.action.reinstall.status=Reinstalando
arch.action.reinstall.confirm=Desea reinstalar {} ?
arch.action.reinstall.error.no_apidata=No fue posible recuperar información de {} del AUR
arch.aur.action.edit_pkgbuild.body=Editar el archivo PKGBUILD de {} antes de continuar ? arch.aur.action.edit_pkgbuild.body=Editar el archivo PKGBUILD de {} antes de continuar ?
arch.aur.install.pgp.body=Para instalar {} es necesario recibir las siguientes claves PGP arch.aur.install.pgp.body=Para instalar {} es necesario recibir las siguientes claves PGP
arch.aur.install.pgp.receive_fail=Could not receive PGP key {} arch.aur.install.pgp.receive_fail=Could not receive PGP key {}

View File

@@ -9,6 +9,10 @@ arch.action.disable_pkgbuild_edition.status=Décocher PKGBUILD comme éditable
arch.action.enable_pkgbuild_edition=Cocher PKGBUILD comme éditable arch.action.enable_pkgbuild_edition=Cocher PKGBUILD comme éditable
arch.action.enable_pkgbuild_edition.confirm=Cocher le PKGBUILD de {} comme éditable ? arch.action.enable_pkgbuild_edition.confirm=Cocher le PKGBUILD de {} comme éditable ?
arch.action.enable_pkgbuild_edition.status=Le PKGBUILD devient éditable arch.action.enable_pkgbuild_edition.status=Le PKGBUILD devient éditable
arch.action.reinstall=Reinstall
arch.action.reinstall.status=Reinstalling
arch.action.reinstall.confirm=Do you want to reinstall {} ?
arch.action.reinstall.error.no_apidata=It was not possible to retrieve information of {} from AUR
arch.aur.action.edit_pkgbuild.body=Editer le fichier PKGBUILD de {} avant de continuer ? arch.aur.action.edit_pkgbuild.body=Editer le fichier PKGBUILD de {} avant de continuer ?
arch.aur.install.pgp.body=Il faut installer {} pour recevoir les clés PGP suivantes arch.aur.install.pgp.body=Il faut installer {} pour recevoir les clés PGP suivantes
arch.aur.install.pgp.receive_fail=Échec de la réception de la clé PGP {} arch.aur.install.pgp.receive_fail=Échec de la réception de la clé PGP {}

View File

@@ -9,6 +9,10 @@ arch.action.disable_pkgbuild_edition.status=Unmarking PKGBUILD as editable
arch.action.enable_pkgbuild_edition=Mark PKGBUILD as editable arch.action.enable_pkgbuild_edition=Mark PKGBUILD as editable
arch.action.enable_pkgbuild_edition.confirm=Mark PKGBUILD of {} as editable ? arch.action.enable_pkgbuild_edition.confirm=Mark PKGBUILD of {} as editable ?
arch.action.enable_pkgbuild_edition.status=Marking PKGBUILD as editable arch.action.enable_pkgbuild_edition.status=Marking PKGBUILD as editable
arch.action.reinstall=Reinstall
arch.action.reinstall.status=Reinstalling
arch.action.reinstall.confirm=Do you want to reinstall {} ?
arch.action.reinstall.error.no_apidata=It was not possible to retrieve information of {} from AUR
arch.aur.action.edit_pkgbuild.body=Edit the PKGBUILD file of {} before continuing ? arch.aur.action.edit_pkgbuild.body=Edit the PKGBUILD file of {} before continuing ?
arch.aur.install.pgp.body=Per installare {} è necessario ricevere le seguenti chiavi PGP arch.aur.install.pgp.body=Per installare {} è necessario ricevere le seguenti chiavi PGP
arch.aur.install.pgp.receive_fail=Impossibile ricevere la chiave PGP {} arch.aur.install.pgp.receive_fail=Impossibile ricevere la chiave PGP {}

View File

@@ -9,6 +9,10 @@ arch.action.disable_pkgbuild_edition.status=Desmarcando PKGBUILD como editável
arch.action.enable_pkgbuild_edition=Marcando PKGBUILD como editável arch.action.enable_pkgbuild_edition=Marcando PKGBUILD como editável
arch.action.enable_pkgbuild_edition.confirm=Marcar o PKGBUILD de {} como editável ? arch.action.enable_pkgbuild_edition.confirm=Marcar o PKGBUILD de {} como editável ?
arch.action.enable_pkgbuild_edition.status=Marcando PKGBUILD como editável arch.action.enable_pkgbuild_edition.status=Marcando PKGBUILD como editável
arch.action.reinstall=Reinstalar
arch.action.reinstall.status=Reinstalando
arch.action.reinstall.confirm=Deseja reinstalar {} ?
arch.action.reinstall.error.no_apidata=Não foi possível obter informações de {} do AUR
arch.aur.action.edit_pkgbuild.body=Editar o arquivo PKGBUILD de {} antes de continuar ? arch.aur.action.edit_pkgbuild.body=Editar o arquivo PKGBUILD de {} antes de continuar ?
arch.aur.install.pgp.body=Para instalar {} é necessário receber as seguintes chaves PGP arch.aur.install.pgp.body=Para instalar {} é necessário receber as seguintes chaves PGP
arch.aur.install.pgp.receive_fail=Não foi possível receber a chave PGP {} arch.aur.install.pgp.receive_fail=Não foi possível receber a chave PGP {}

View File

@@ -9,6 +9,10 @@ arch.action.disable_pkgbuild_edition.status=Unmarking PKGBUILD as editable
arch.action.enable_pkgbuild_edition=Mark PKGBUILD as editable arch.action.enable_pkgbuild_edition=Mark PKGBUILD as editable
arch.action.enable_pkgbuild_edition.confirm=Mark PKGBUILD of {} as editable ? arch.action.enable_pkgbuild_edition.confirm=Mark PKGBUILD of {} as editable ?
arch.action.enable_pkgbuild_edition.status=Marking PKGBUILD as editable arch.action.enable_pkgbuild_edition.status=Marking PKGBUILD as editable
arch.action.reinstall=Reinstall
arch.action.reinstall.status=Reinstalling
arch.action.reinstall.confirm=Do you want to reinstall {} ?
arch.action.reinstall.error.no_apidata=It was not possible to retrieve information of {} from AUR
arch.aur.action.edit_pkgbuild.body=Edit the PKGBUILD file of {} before continuing ? arch.aur.action.edit_pkgbuild.body=Edit the PKGBUILD file of {} before continuing ?
arch.aur.install.pgp.body=Для установки {} необходимо получить следующие PGP ключи arch.aur.install.pgp.body=Для установки {} необходимо получить следующие PGP ключи
arch.aur.install.pgp.receive_fail=Не удалось получить PGP-ключ {} arch.aur.install.pgp.receive_fail=Не удалось получить PGP-ключ {}

View File

@@ -9,6 +9,10 @@ arch.action.disable_pkgbuild_edition.status=Unmarking PKGBUILD as editable
arch.action.enable_pkgbuild_edition=Mark PKGBUILD as editable arch.action.enable_pkgbuild_edition=Mark PKGBUILD as editable
arch.action.enable_pkgbuild_edition.confirm=Mark PKGBUILD of {} as editable ? arch.action.enable_pkgbuild_edition.confirm=Mark PKGBUILD of {} as editable ?
arch.action.enable_pkgbuild_edition.status=Marking PKGBUILD as editable arch.action.enable_pkgbuild_edition.status=Marking PKGBUILD as editable
arch.action.reinstall=Reinstall
arch.action.reinstall.status=Reinstalling
arch.action.reinstall.confirm=Do you want to reinstall {} ?
arch.action.reinstall.error.no_apidata=It was not possible to retrieve information of {} from AUR
arch.aur.action.edit_pkgbuild.body=Edit the PKGBUILD file of {} before continuing ? arch.aur.action.edit_pkgbuild.body=Edit the PKGBUILD file of {} before continuing ?
arch.aur.install.pgp.body={} kurmak için aşağıdaki PGP anahtarlarını almak gereklidir arch.aur.install.pgp.body={} kurmak için aşağıdaki PGP anahtarlarını almak gereklidir
arch.aur.install.pgp.receive_fail=PGP anahtarı alınamadı {} arch.aur.install.pgp.receive_fail=PGP anahtarı alınamadı {}

View File

@@ -22,6 +22,7 @@ class AsyncDiskCacheLoader(Thread, DiskCacheLoader):
self.cache_map = cache_map self.cache_map = cache_map
self.logger = logger self.logger = logger
self.processed = 0 self.processed = 0
self._working = False
def fill(self, pkg: SoftwarePackage, sync: bool = False): def fill(self, pkg: SoftwarePackage, sync: bool = False):
""" """
@@ -31,7 +32,7 @@ class AsyncDiskCacheLoader(Thread, DiskCacheLoader):
:return: :return:
""" """
if pkg and pkg.supports_disk_cache(): if pkg and pkg.supports_disk_cache():
if sync: if sync or not self._working:
self._fill_cached_data(pkg) self._fill_cached_data(pkg)
else: else:
self.pkgs.append(pkg) self.pkgs.append(pkg)
@@ -40,6 +41,7 @@ class AsyncDiskCacheLoader(Thread, DiskCacheLoader):
self._work = False self._work = False
def run(self): def run(self):
self._working = True
last = 0 last = 0
while True: while True:
@@ -53,6 +55,8 @@ class AsyncDiskCacheLoader(Thread, DiskCacheLoader):
elif not self._work: elif not self._work:
break break
self._working = False
def _fill_cached_data(self, pkg: SoftwarePackage) -> bool: def _fill_cached_data(self, pkg: SoftwarePackage) -> bool:
if os.path.exists(pkg.get_disk_data_path()): if os.path.exists(pkg.get_disk_data_path()):
disk_path = pkg.get_disk_data_path() disk_path = pkg.get_disk_data_path()