From 5df45627eee1e94726757a465707023f42f893af Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Tue, 22 Oct 2019 17:24:39 -0300 Subject: [PATCH] [aur] caching the package categories to the disk --- CHANGELOG.md | 4 ++-- bauh/gems/arch/controller.py | 2 +- bauh/gems/arch/disk.py | 5 ++++- bauh/gems/arch/model.py | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 259e6710..ac702efa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,10 +16,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - AUR: - showing a "user-friendly" popup when there are integrity issues with the source-files of a building package - not waiting for the categories file to be retrieved from the cloud during application boot ( reduces boot time ) - - caching cloud to categories to the disk so they can be used in scenarios when it is not possible to retrieve them ( e.g: internet is off ) + - caching cloud categories to the disk so they can be used in scenarios when it is not possible to retrieve them ( e.g: internet is off ) - Snap: - not waiting for the categories file to be retrieved from the cloud during application boot ( reduces boot time ) - - caching cloud to categories to the disk so they can be used in scenarios when it is not possible to retrieve them ( e.g: internet is off ) + - caching cloud categories to the disk so they can be used in scenarios when it is not possible to retrieve them ( e.g: internet is off ) - minor thread improvements ### Fixes diff --git a/bauh/gems/arch/controller.py b/bauh/gems/arch/controller.py index 2b7934a2..e3f811be 100644 --- a/bauh/gems/arch/controller.py +++ b/bauh/gems/arch/controller.py @@ -568,7 +568,7 @@ class ArchManager(SoftwareManager): if installed and self.context.disk_cache: handler.watcher.change_substatus(self.i18n['status.caching_data'].format(bold(pkgname))) if self.context.disk_cache: - disk.save_several({pkgname}, mirror=mirror, maintainer=maintainer, overwrite=True) + disk.save_several({pkgname}, mirror=mirror, maintainer=maintainer, overwrite=True, categories=self.categories) self._update_progress(handler.watcher, 100, change_progress) diff --git a/bauh/gems/arch/disk.py b/bauh/gems/arch/disk.py index 9e012f05..124a6a66 100644 --- a/bauh/gems/arch/disk.py +++ b/bauh/gems/arch/disk.py @@ -47,7 +47,7 @@ def set_icon_path(app: ArchPackage, icon_name: str = None): break -def save_several(pkgnames: Set[str], mirror: str, overwrite: bool = True, maintainer: str = None) -> int: +def save_several(pkgnames: Set[str], mirror: str, overwrite: bool = True, maintainer: str = None, categories: dict = None) -> int: to_cache = {n for n in pkgnames if overwrite or not os.path.exists(ArchPackage.disk_cache_path(n, mirror))} desktop_files = pacman.list_desktop_entries(to_cache) @@ -138,6 +138,9 @@ def save_several(pkgnames: Set[str], mirror: str, overwrite: bool = True, mainta if to_write: for p in to_write: + if categories: + p.categories = categories.get(p.name) + p.maintainer = maintainer write(p) return len(to_write) diff --git a/bauh/gems/arch/model.py b/bauh/gems/arch/model.py index 9da563eb..62d6d5fb 100644 --- a/bauh/gems/arch/model.py +++ b/bauh/gems/arch/model.py @@ -5,7 +5,7 @@ from bauh.api.abstract.model import SoftwarePackage from bauh.commons import resource from bauh.gems.arch import ROOT_DIR, ARCH_CACHE_PATH -CACHED_ATTRS = {'command', 'icon_path', 'mirror', 'maintainer', 'desktop_entry'} +CACHED_ATTRS = {'command', 'icon_path', 'mirror', 'maintainer', 'desktop_entry', 'categories'} class ArchPackage(SoftwarePackage):