mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-09 07:34:16 +02:00
[fix][arch] not waiting for the disk cache to be ready before reading installed packages
This commit is contained in:
@@ -65,7 +65,7 @@ class TransactionContext:
|
|||||||
remote_repo_map: Dict[str, str] = None, provided_map: Dict[str, Set[str]] = None,
|
remote_repo_map: Dict[str, str] = None, provided_map: Dict[str, Set[str]] = None,
|
||||||
remote_provided_map: Dict[str, Set[str]] = None, aur_idx: Set[str] = None,
|
remote_provided_map: Dict[str, Set[str]] = None, aur_idx: Set[str] = None,
|
||||||
missing_deps: List[Tuple[str, str]] = None, installed: Set[str] = None, removed: Dict[str, SoftwarePackage] = None,
|
missing_deps: List[Tuple[str, str]] = None, installed: Set[str] = None, removed: Dict[str, SoftwarePackage] = None,
|
||||||
disk_loader: DiskCacheLoader = None):
|
disk_loader: DiskCacheLoader = None, disk_cache_updater: Thread = None):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.base = base
|
self.base = base
|
||||||
self.maintainer = maintainer
|
self.maintainer = maintainer
|
||||||
@@ -89,6 +89,7 @@ class TransactionContext:
|
|||||||
self.installed = installed
|
self.installed = installed
|
||||||
self.removed = removed
|
self.removed = removed
|
||||||
self.disk_loader = disk_loader
|
self.disk_loader = disk_loader
|
||||||
|
self.disk_cache_updater = disk_cache_updater
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def gen_context_from(cls, pkg: ArchPackage, arch_config: dict, root_password: str, handler: ProcessHandler) -> "TransactionContext":
|
def gen_context_from(cls, pkg: ArchPackage, arch_config: dict, root_password: str, handler: ProcessHandler) -> "TransactionContext":
|
||||||
@@ -156,7 +157,7 @@ class TransactionContext:
|
|||||||
|
|
||||||
class ArchManager(SoftwareManager):
|
class ArchManager(SoftwareManager):
|
||||||
|
|
||||||
def __init__(self, context: ApplicationContext):
|
def __init__(self, context: ApplicationContext, disk_cache_updater: ArchDiskCacheUpdater = None):
|
||||||
super(ArchManager, self).__init__(context=context)
|
super(ArchManager, self).__init__(context=context)
|
||||||
self.aur_cache = context.cache_factory.new()
|
self.aur_cache = context.cache_factory.new()
|
||||||
# context.disk_loader_factory.map(ArchPackage, self.aur_cache) TODO
|
# context.disk_loader_factory.map(ArchPackage, self.aur_cache) TODO
|
||||||
@@ -201,6 +202,7 @@ class ArchManager(SoftwareManager):
|
|||||||
}
|
}
|
||||||
self.index_aur = None
|
self.index_aur = None
|
||||||
self.re_file_conflict = re.compile(r'[\w\d\-_.]+:')
|
self.re_file_conflict = re.compile(r'[\w\d\-_.]+:')
|
||||||
|
self.disk_cache_updater = disk_cache_updater
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_semantic_search_map() -> Dict[str, str]:
|
def get_semantic_search_map() -> Dict[str, str]:
|
||||||
@@ -494,6 +496,12 @@ class ArchManager(SoftwareManager):
|
|||||||
|
|
||||||
pkgs.append(pkg)
|
pkgs.append(pkg)
|
||||||
|
|
||||||
|
def _wait_for_disk_cache(self):
|
||||||
|
if self.disk_cache_updater and self.disk_cache_updater.is_alive():
|
||||||
|
self.logger.info("Waiting for disk cache path be ready")
|
||||||
|
self.disk_cache_updater.join()
|
||||||
|
self.logger.info("Disk cache ready")
|
||||||
|
|
||||||
def read_installed(self, disk_loader: DiskCacheLoader, limit: int = -1, only_apps: bool = False, pkg_types: Set[Type[SoftwarePackage]] = None, internet_available: bool = None, names: Iterable[str] = None) -> SearchResult:
|
def read_installed(self, disk_loader: DiskCacheLoader, limit: int = -1, only_apps: bool = False, pkg_types: Set[Type[SoftwarePackage]] = None, internet_available: bool = None, names: Iterable[str] = None) -> SearchResult:
|
||||||
self.aur_client.clean_caches()
|
self.aur_client.clean_caches()
|
||||||
arch_config = read_config()
|
arch_config = read_config()
|
||||||
@@ -524,6 +532,8 @@ class ArchManager(SoftwareManager):
|
|||||||
|
|
||||||
pkgs = []
|
pkgs = []
|
||||||
if repo_pkgs or aur_pkgs:
|
if repo_pkgs or aur_pkgs:
|
||||||
|
self._wait_for_disk_cache()
|
||||||
|
|
||||||
map_threads = []
|
map_threads = []
|
||||||
|
|
||||||
if aur_pkgs:
|
if aur_pkgs:
|
||||||
@@ -2062,8 +2072,13 @@ class ArchManager(SoftwareManager):
|
|||||||
arch_config = read_config(update_file=True)
|
arch_config = read_config(update_file=True)
|
||||||
|
|
||||||
if arch_config['aur'] or arch_config['repositories']:
|
if arch_config['aur'] or arch_config['repositories']:
|
||||||
ArchDiskCacheUpdater(task_man=task_manager, arch_config=arch_config, i18n=self.i18n, logger=self.context.logger,
|
self.disk_cache_updater = ArchDiskCacheUpdater(task_man=task_manager,
|
||||||
controller=self, internet_available=internet_available).start()
|
arch_config=arch_config,
|
||||||
|
i18n=self.i18n,
|
||||||
|
logger=self.context.logger,
|
||||||
|
controller=self,
|
||||||
|
internet_available=internet_available)
|
||||||
|
self.disk_cache_updater.start()
|
||||||
|
|
||||||
if arch_config['aur']:
|
if arch_config['aur']:
|
||||||
ArchCompilationOptimizer(arch_config, self.i18n, self.context.logger, task_manager).start()
|
ArchCompilationOptimizer(arch_config, self.i18n, self.context.logger, task_manager).start()
|
||||||
|
|||||||
Reference in New Issue
Block a user