Merge branch 'staging' into modules

# Conflicts:
#	fpakman/core/controller.py
This commit is contained in:
Vinicius Moreira
2019-08-07 14:08:19 -03:00
2 changed files with 16 additions and 8 deletions

View File

@@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [0.5.1] ## [0.5.1]
### Improvements: ### Improvements:
- suggestions are now retrieved asynchronously. Response time takes 45% less. - suggestions are now retrieved asynchronously. Response time takes 45% less.
- search response time takes an average of 20% less ( reaching 35% for several results )
### Fixes: ### Fixes:
- [flatpak dependency](https://github.com/vinifmor/fpakman/issues/36) - [flatpak dependency](https://github.com/vinifmor/fpakman/issues/36)

View File

@@ -56,21 +56,28 @@ class GenericApplicationManager(ApplicationManager):
else: else:
return man.is_enabled() return man.is_enabled()
def _search(self, word: str, man: ApplicationManager, disk_loader, res: dict):
if self._is_enabled(man):
apps_found = man.search(words=word, disk_loader=disk_loader)
res['installed'].extend(apps_found['installed'])
res['new'].extend(apps_found['new'])
def search(self, word: str, disk_loader: DiskCacheLoader = None) -> Dict[str, List[Application]]: def search(self, word: str, disk_loader: DiskCacheLoader = None) -> Dict[str, List[Application]]:
res = {'installed': [], 'new': []} res = {'installed': [], 'new': []}
norm_word = word.strip().lower() norm_word = word.strip().lower()
disk_loader = None disk_loader = self.disk_loader_factory.new()
disk_loader.start()
threads = []
for man in self.managers: for man in self.managers:
if self._is_enabled(man): t = Thread(target=self._search, args=(norm_word, man, disk_loader, res))
if not disk_loader: t.start()
disk_loader = self.disk_loader_factory.new() threads.append(t)
disk_loader.start()
apps_found = man.search(words=norm_word, disk_loader=disk_loader) for t in threads:
res['installed'].extend(apps_found['installed']) t.join()
res['new'].extend(apps_found['new'])
if disk_loader: if disk_loader:
disk_loader.stop = True disk_loader.stop = True