mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-06 22:54:16 +02:00
arch: fix disk cache | wait disk cache to finish before first refresh
This commit is contained in:
@@ -121,6 +121,7 @@ class ArchManager(SoftwareManager):
|
||||
|
||||
apps = []
|
||||
if installed and installed['not_signed']:
|
||||
self.dcache_updater.join()
|
||||
self._fill_aur_pkgs(installed['not_signed'], apps, disk_loader)
|
||||
|
||||
return SearchResult(apps, None, len(apps))
|
||||
@@ -335,7 +336,7 @@ class ArchManager(SoftwareManager):
|
||||
|
||||
# building main package
|
||||
handler.watcher.change_substatus(self.i18n['arch.building.package'].format(bold(pkgname)))
|
||||
pkgbuilt = handler.handle(SystemProcess(new_subprocess(['makepkg', '-Acsmf'], cwd=project_dir)))
|
||||
pkgbuilt = handler.handle(SystemProcess(new_subprocess(['makepkg', '-ALcsmf'], cwd=project_dir)))
|
||||
self._update_progress(handler.watcher, 65, change_progress)
|
||||
|
||||
if pkgbuilt:
|
||||
@@ -452,7 +453,7 @@ class ArchManager(SoftwareManager):
|
||||
|
||||
if installed and self.context.disk_cache:
|
||||
handler.watcher.change_substatus(self.i18n['status.caching_data'].format(bold(pkgname)))
|
||||
disk.save(pkgname, mirror)
|
||||
disk.save_several({pkgname}, mirror)
|
||||
self._update_progress(handler.watcher, 100, change_progress)
|
||||
|
||||
return installed
|
||||
|
||||
@@ -12,14 +12,17 @@ RE_CLEAN_NAME = re.compile(r'^(\w+)-?|_?.+')
|
||||
|
||||
|
||||
def write(app: ArchPackage):
|
||||
Path(app.get_disk_cache_path()).mkdir(parents=True, exist_ok=True)
|
||||
data = app.get_data_to_cache()
|
||||
|
||||
with open(app.get_disk_data_path(), 'w+') as f:
|
||||
f.write(json.dumps(app.get_data_to_cache()))
|
||||
if data:
|
||||
Path(app.get_disk_cache_path()).mkdir(parents=True, exist_ok=True)
|
||||
|
||||
with open(app.get_disk_data_path(), 'w+') as f:
|
||||
f.write(json.dumps(data))
|
||||
|
||||
|
||||
def fill_icon_path(app: ArchPackage, icon_paths: List[str], only_exact_match: bool):
|
||||
ends_with = re.compile(r'.+/{}\.(png|svg)$'.format(app.name), re.IGNORECASE)
|
||||
ends_with = re.compile(r'.+/{}\.(png|svg)$'.format(app.icon_path if app.icon_path else app.name), re.IGNORECASE)
|
||||
|
||||
for path in icon_paths:
|
||||
if ends_with.match(path):
|
||||
@@ -30,11 +33,11 @@ def fill_icon_path(app: ArchPackage, icon_paths: List[str], only_exact_match: bo
|
||||
pkg_icons_path = pacman.list_icon_paths({app.name})
|
||||
|
||||
if pkg_icons_path:
|
||||
app.icon_path = pkg_icons_path[0]
|
||||
app.set_icon(pkg_icons_path)
|
||||
|
||||
|
||||
def set_icon_path(app: ArchPackage, icon_name: str = None):
|
||||
installed_icons = pacman.list_icon_paths(app.name)
|
||||
installed_icons = pacman.list_icon_paths({app.name})
|
||||
|
||||
if installed_icons:
|
||||
exact_match = re.compile(r'.+/{}\..+$'.format(icon_name.split('.')[0] if icon_name else app.name))
|
||||
@@ -60,11 +63,16 @@ def save(pkgname: str, mirror: str):
|
||||
with open(to_parse) as f:
|
||||
desktop_entry = f.read()
|
||||
|
||||
icons_found = []
|
||||
|
||||
for field in RE_DESKTOP_ENTRY.findall(desktop_entry):
|
||||
if field[0] == 'Exec':
|
||||
app.command = field[1].strip()
|
||||
elif field[0] == 'Icon':
|
||||
app.icon_path = field[1].strip()
|
||||
icons_found.append(field[1].strip())
|
||||
|
||||
if icons_found:
|
||||
app.set_icon(icons_found)
|
||||
|
||||
if app.icon_path and '/' not in app.icon_path: # if the icon full path is not defined
|
||||
set_icon_path(app, app.icon_path)
|
||||
@@ -80,10 +88,7 @@ def save(pkgname: str, mirror: str):
|
||||
|
||||
set_icon_path(app)
|
||||
|
||||
Path(app.get_disk_cache_path()).mkdir(parents=True, exist_ok=True)
|
||||
|
||||
with open(app.get_disk_data_path(), 'w+') as f:
|
||||
f.write(json.dumps(app.get_data_to_cache()))
|
||||
write(app)
|
||||
|
||||
|
||||
def save_several(pkgnames: Set[str], mirror: str, overwrite: bool = True) -> int:
|
||||
@@ -105,7 +110,6 @@ def save_several(pkgnames: Set[str], mirror: str, overwrite: bool = True) -> int
|
||||
|
||||
if pkg not in desktop_matches:
|
||||
no_exact_match.add(pkg)
|
||||
|
||||
if no_exact_match: # check every not matched app individually
|
||||
for pkg in no_exact_match:
|
||||
entries = pacman.list_desktop_entries({pkg})
|
||||
@@ -117,6 +121,7 @@ def save_several(pkgnames: Set[str], mirror: str, overwrite: bool = True) -> int
|
||||
for e in entries:
|
||||
if e.startswith('/usr/share/applications'):
|
||||
desktop_matches[pkg] = e
|
||||
break
|
||||
|
||||
if not desktop_matches:
|
||||
no_desktop_files = to_cache
|
||||
@@ -146,7 +151,6 @@ def save_several(pkgnames: Set[str], mirror: str, overwrite: bool = True) -> int
|
||||
|
||||
if apps_icons_noabspath:
|
||||
icon_paths = pacman.list_icon_paths({app.name for app in apps_icons_noabspath})
|
||||
|
||||
if icon_paths:
|
||||
for p in apps_icons_noabspath:
|
||||
fill_icon_path(p, icon_paths, False)
|
||||
|
||||
@@ -8,18 +8,21 @@ RE_DEPS_PATTERN = re.compile(r'\n?\s+->\s(.+)\n')
|
||||
|
||||
|
||||
def check_missing_deps(pkgdir: str, watcher: ProcessWatcher) -> List[str]:
|
||||
depcheck = new_subprocess(['makepkg', '--check'], cwd=pkgdir)
|
||||
depcheck = new_subprocess(['makepkg', '-L', '--check'], cwd=pkgdir)
|
||||
|
||||
for o in depcheck.stdout:
|
||||
if o:
|
||||
watcher.print(o.decode())
|
||||
line = o.decode().strip()
|
||||
|
||||
if line:
|
||||
watcher.print(line)
|
||||
|
||||
error_lines = []
|
||||
for s in depcheck.stderr:
|
||||
if s:
|
||||
line = s.decode()
|
||||
print(line)
|
||||
error_lines.append(line)
|
||||
line = s.decode().strip()
|
||||
if line:
|
||||
error_lines.append(line)
|
||||
|
||||
if error_lines:
|
||||
error_str = ''.join(error_lines)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import datetime
|
||||
from typing import List
|
||||
|
||||
from bauh.api.abstract.model import SoftwarePackage
|
||||
from bauh.api.constants import CACHE_PATH
|
||||
@@ -81,8 +82,6 @@ class ArchPackage(SoftwarePackage):
|
||||
|
||||
if val:
|
||||
cache[a] = val
|
||||
else:
|
||||
return None
|
||||
|
||||
if self.desktop_entry:
|
||||
cache['desktop_entry'] = self.desktop_entry
|
||||
@@ -108,3 +107,20 @@ class ArchPackage(SoftwarePackage):
|
||||
|
||||
def get_publisher(self):
|
||||
return self.maintainer
|
||||
|
||||
def set_icon(self, paths: List[str]):
|
||||
self.icon_path = paths[0]
|
||||
|
||||
if len(paths) > 1:
|
||||
for path in paths:
|
||||
if '/' in path:
|
||||
self.icon_path = path
|
||||
break
|
||||
|
||||
self.icon_url = self.icon_path
|
||||
|
||||
def __str__(self):
|
||||
return self.__repr__()
|
||||
|
||||
def __repr__(self):
|
||||
return '{} (name={}, command={}, icon_path={})'.format(self.__class__.__name__, self.name, self.command, self.icon_path)
|
||||
|
||||
@@ -99,10 +99,10 @@ def install_as_process(pkgpath: str, root_password: str, aur: bool, pkgdir: str
|
||||
|
||||
def list_desktop_entries(pkgnames: Set[str]) -> List[str]:
|
||||
if pkgnames:
|
||||
installed_files = new_subprocess(['pacman', '-Qlq', *pkgnames]).stdout
|
||||
installed_files = new_subprocess(['pacman', '-Qlq', *pkgnames])
|
||||
|
||||
desktop_files = []
|
||||
for out in new_subprocess(['grep', '-E', '.desktop'], stdin=installed_files).stdout:
|
||||
for out in new_subprocess(['grep', '-E', '.desktop'], stdin=installed_files.stdout).stdout:
|
||||
if out:
|
||||
desktop_files.append(out.decode().strip())
|
||||
|
||||
@@ -110,22 +110,26 @@ def list_desktop_entries(pkgnames: Set[str]) -> List[str]:
|
||||
|
||||
|
||||
def list_icon_paths(pkgnames: Set[str]) -> List[str]:
|
||||
installed_files = new_subprocess(['pacman', '-Qlq', *pkgnames]).stdout
|
||||
installed_files = new_subprocess(['pacman', '-Qlq', *pkgnames])
|
||||
|
||||
icon_files = []
|
||||
for out in new_subprocess(['grep', '-E', '.(png|svg|jpeg)'], stdin=installed_files).stdout:
|
||||
for out in new_subprocess(['grep', '-E', '.(png|svg)'], stdin=installed_files.stdout).stdout:
|
||||
if out:
|
||||
icon_files.append(out.decode().strip())
|
||||
line = out.decode().strip()
|
||||
if line:
|
||||
icon_files.append(line)
|
||||
|
||||
return icon_files
|
||||
|
||||
|
||||
def list_bin_paths(pkgnames: Set[str]) -> List[str]:
|
||||
installed_files = new_subprocess(['pacman', '-Qlq', *pkgnames]).stdout
|
||||
installed_files = new_subprocess(['pacman', '-Qlq', *pkgnames])
|
||||
|
||||
bin_paths = []
|
||||
for out in new_subprocess(['grep', '-E', '^/usr/bin/.+'], stdin=installed_files).stdout:
|
||||
for out in new_subprocess(['grep', '-E', '^/usr/bin/.+'], stdin=installed_files.stdout).stdout:
|
||||
if out:
|
||||
bin_paths.append(out.decode().strip())
|
||||
line = out.decode().strip()
|
||||
if line:
|
||||
bin_paths.append(line)
|
||||
|
||||
return bin_paths
|
||||
|
||||
@@ -13,10 +13,8 @@ class ConfirmationDialog(QMessageBox):
|
||||
self.setWindowTitle(title)
|
||||
self.setStyleSheet('QLabel { margin-right: 25px; }')
|
||||
self.bt_yes = self.addButton(locale_keys['popup.button.yes'] if not confirmation_label else confirmation_label.capitalize(), QMessageBox.YesRole)
|
||||
self.bt_yes.setStyleSheet('background: green; color: white; font-weight: bold')
|
||||
|
||||
bt_no = self.addButton(locale_keys['popup.button.no'] if not deny_label else deny_label.capitalize(), QMessageBox.NoRole)
|
||||
bt_no.setStyleSheet('background: red; color: white; font-weight: bold')
|
||||
self.addButton(locale_keys['popup.button.no'] if not deny_label else deny_label.capitalize(), QMessageBox.NoRole)
|
||||
|
||||
if body:
|
||||
if not components:
|
||||
|
||||
@@ -42,10 +42,8 @@ def ask_confirmation(title: str, body: str, locale_keys: dict, icon: QIcon = QIc
|
||||
diag.layout().addWidget(wbody, 0, 1)
|
||||
|
||||
bt_yes = diag.addButton(locale_keys['popup.button.yes'], QMessageBox.YesRole)
|
||||
bt_yes.setStyleSheet('background: green; color: white; font-weight: bold')
|
||||
|
||||
bt_no = diag.addButton(locale_keys['popup.button.no'], QMessageBox.NoRole)
|
||||
bt_no.setStyleSheet('background: red; color: white; font-weight: bold')
|
||||
diag.addButton(locale_keys['popup.button.no'], QMessageBox.NoRole)
|
||||
|
||||
if icon:
|
||||
diag.setWindowIcon(icon)
|
||||
|
||||
Reference in New Issue
Block a user