diff --git a/CHANGELOG.md b/CHANGELOG.md
index e08d4826..1c486101 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,12 +11,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Improvements
- Arch
- - AUR:
+ - AUR
- upgrade checking now considers modification dates as well (needed because not all AUR packages follow versioning standards)
- downgrade: using the cached package commit (if available) to determine the correct version to downgrade to (otherwise only the version will be used -> old behavior)
- history: using the cached package commit (if available) to properly determine the current version (otherwise only the version will be used -> old behavior)
- - the task responsible for generating a local AUR index is displayed on the initialization dialog
- - info window:
+ - the task responsible for generating the local index is displayed on the initialization dialog
+ - the index is not always being updated during the initialization process. It its kept for a period of time controlled by the settings property **aur_idx_exp** (in minutes -> default: 720 = 8 hours.). (P.S: this index is always updated when a package is installed/upgraded)
+
+
+
+
+ - the index is now stored at **~/.cache/bauh/arch/aur/index.txt**.
+ - info window
- date fields format changed to numbers (e.g: Thu Dec 17 17:19:55 2020 -> 2020-12-17 17:19:55)
### Fixes
@@ -29,6 +35,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Flatpak
- crashing for Flatpak 1.6.5 when there are updates [#145](https://github.com/vinifmor/bauh/issues/145)
- history: not highlighting the correct version (regression introduced **0.9.9**)
+- UI
+ - number input fields are not displaying **0**
## [0.9.10] 2020-12-11
diff --git a/README.md b/README.md
index 33586c69..c8a5c9dc 100644
--- a/README.md
+++ b/README.md
@@ -206,6 +206,7 @@ edit_aur_pkgbuild: false # if the AUR PKGBUILD file should be displayed for edi
aur_build_dir: null # defines a custom build directory for AUR packages (a null value will point to /tmp/bauh/arch (non-root user) or /tmp/bauh_root/arch (root user)). Default: null.
aur_remove_build_dir: true # it defines if a package's generated build directory should be removed after the operation is finished (installation, upgrading, ...). Options: true, false (default: true).
aur_build_only_chosen : true # some AUR packages have a common file definition declaring several packages to be built. When this property is 'true' only the package the user select to install will be built (unless its name is different from those declared in the PKGBUILD base). With a 'null' value a popup asking if the user wants to build all of them will be displayed. 'false' will build and install all packages. Default: true.
+aur_idx_exp: 720 # It defines the period (in minutes) for the AUR index stored in disc to be considered valid during the initialization process. Use 0 so that it is always updated. Default: 720 (12 hours). (P.S: this index is always updated when a package is installed/upgraded)
check_dependency_breakage: true # if, during the verification of the update requirements, specific versions of dependencies must also be checked. Example: package A depends on version 1.0 of B. If A and B were selected to upgrade, and B would be upgrade to 2.0, then B would be excluded from the transaction. Default: true.
suggest_unneeded_uninstall: false # if the dependencies apparently no longer necessary associated with the uninstalled packages should be suggested for uninstallation. When this property is enabled it automatically disables the property 'suggest_optdep_uninstall'. Default: false (to prevent new users from making mistakes)
suggest_optdep_uninstall: false # if the optional dependencies associated with uninstalled packages should be suggested for uninstallation. Only the optional dependencies that are not dependencies of other packages will be suggested. Default: false (to prevent new users from making mistakes)
diff --git a/bauh/api/abstract/view.py b/bauh/api/abstract/view.py
index a760ceb1..30743b38 100644
--- a/bauh/api/abstract/view.py
+++ b/bauh/api/abstract/view.py
@@ -191,11 +191,11 @@ class TextInputComponent(ViewComponent):
if caller != o:
o.on_change(val)
- def get_int_value(self) -> int:
+ def get_int_value(self) -> Optional[int]:
if self.value is not None:
val = self.value.strip() if isinstance(self.value, str) else self.value
- if val:
+ if val is not None:
return int(self.value)
def get_label(self) -> str:
diff --git a/bauh/commons/util.py b/bauh/commons/util.py
index 7a202d95..444dfa70 100644
--- a/bauh/commons/util.py
+++ b/bauh/commons/util.py
@@ -28,5 +28,5 @@ def size_to_byte(size: float, unit: str) -> int:
return int(final_size)
-def datetime_as_milis(date: datetime) -> int:
+def datetime_as_milis(date: datetime = datetime.utcnow()) -> int:
return int(round(date.timestamp() * 1000))
diff --git a/bauh/gems/arch/__init__.py b/bauh/gems/arch/__init__.py
index 9751ae48..5350f171 100644
--- a/bauh/gems/arch/__init__.py
+++ b/bauh/gems/arch/__init__.py
@@ -12,7 +12,8 @@ URL_CATEGORIES_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/mas
URL_GPG_SERVERS = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/arch/gpgservers.txt'
CONFIG_DIR = '{}/.config/bauh/arch'.format(str(Path.home()))
CUSTOM_MAKEPKG_FILE = '{}/makepkg.conf'.format(CONFIG_DIR)
-AUR_INDEX_FILE = '{}/arch.txt'.format(BUILD_DIR)
+AUR_INDEX_FILE = '{}/aur/index.txt'.format(ARCH_CACHE_PATH)
+AUR_INDEX_TS_FILE = '{}/aur/index.ts'.format(ARCH_CACHE_PATH)
CONFIG_FILE = '{}/arch.yml'.format(CONFIG_PATH)
SUGGESTIONS_FILE = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/arch/aur_suggestions.txt'
UPDATES_IGNORED_FILE = '{}/updates_ignored.txt'.format(CONFIG_DIR)
diff --git a/bauh/gems/arch/config.py b/bauh/gems/arch/config.py
index 2fd89b1b..94d07ecb 100644
--- a/bauh/gems/arch/config.py
+++ b/bauh/gems/arch/config.py
@@ -21,7 +21,8 @@ def read_config(update_file: bool = False) -> dict:
'aur_build_only_chosen': True,
'check_dependency_breakage': True,
'suggest_unneeded_uninstall': False,
- 'suggest_optdep_uninstall': False}
+ 'suggest_optdep_uninstall': False,
+ 'aur_idx_exp': 720}
return read(CONFIG_FILE, template, update_file=update_file)
diff --git a/bauh/gems/arch/controller.py b/bauh/gems/arch/controller.py
index 1581e7b9..d796b51f 100644
--- a/bauh/gems/arch/controller.py
+++ b/bauh/gems/arch/controller.py
@@ -75,7 +75,7 @@ class TransactionContext:
disk_loader: DiskCacheLoader = None, disk_cache_updater: Thread = None,
new_pkg: bool = False, custom_pkgbuild_path: str = None,
pkgs_to_build: Set[str] = None, last_modified: Optional[int] = None,
- commit: Optional[str] = None):
+ commit: Optional[str] = None, update_aur_index: bool = False):
self.aur_supported = aur_supported
self.name = name
self.base = base
@@ -108,6 +108,7 @@ class TransactionContext:
self.previous_change_progress = change_progress
self.last_modified = last_modified
self.commit = commit
+ self.update_aur_index = update_aur_index
@classmethod
def gen_context_from(cls, pkg: ArchPackage, arch_config: dict, root_password: str, handler: ProcessHandler, aur_supported: Optional[bool] = None) -> "TransactionContext":
@@ -1132,6 +1133,7 @@ class ArchManager(SoftwareManager):
if not pkgs_api_data:
self.logger.warning("Could not retrieve the 'last_modified' fields from the AUR API during the upgrade process")
+ any_upgraded = False
for pkg in aur_pkgs:
watcher.change_substatus("{} {} ({})...".format(self.i18n['manage_window.status.upgrading'], pkg.name, pkg.version))
@@ -1149,19 +1151,29 @@ class ArchManager(SoftwareManager):
try:
if not self.install(pkg=pkg, root_password=root_password, watcher=watcher, disk_loader=None, context=context).success:
+ if any_upgraded:
+ self._update_aur_index(watcher)
+
watcher.print(self.i18n['arch.upgrade.fail'].format('"{}"'.format(pkg.name)))
self.logger.error("Could not upgrade AUR package '{}'".format(pkg.name))
watcher.change_substatus('')
return False
else:
+ any_upgraded = True
watcher.print(self.i18n['arch.upgrade.success'].format('"{}"'.format(pkg.name)))
except:
+ if any_upgraded:
+ self._update_aur_index(watcher)
+
watcher.print(self.i18n['arch.upgrade.fail'].format('"{}"'.format(pkg.name)))
watcher.change_substatus('')
self.logger.error("An error occurred when upgrading AUR package '{}'".format(pkg.name))
traceback.print_exc()
return False
+ if any_upgraded:
+ self._update_aur_index(watcher)
+
watcher.change_substatus('')
return True
@@ -1905,6 +1917,9 @@ class ArchManager(SoftwareManager):
if self._install(context=context):
self._save_pkgbuild(context)
+ if context.update_aur_index:
+ self._update_aur_index(context.watcher)
+
if context.dependency or context.skip_opt_deps:
return True
@@ -1917,6 +1932,16 @@ class ArchManager(SoftwareManager):
return False
+ def _update_aur_index(self, watcher: ProcessWatcher):
+ if self.context.internet_checker.is_available():
+ if watcher:
+ watcher.change_substatus(self.i18n['arch.task.aur.index.status'])
+
+ idx_updater = AURIndexUpdater(context=self.context, taskman=TaskManager()) # null task manager
+ idx_updater.run()
+ else:
+ self.logger.warning("Could not update the AUR index: no internet connection detected")
+
def __fill_aur_output_files(self, context: TransactionContext):
self.logger.info("Determining output files of '{}'".format(context.name))
context.watcher.change_substatus(self.i18n['arch.aur.build.list_output'])
@@ -2483,6 +2508,7 @@ class ArchManager(SoftwareManager):
root_password=root_password)
install_context.skip_opt_deps = False
install_context.disk_loader = disk_loader
+ install_context.update_aur_index = pkg.repository == 'aur'
self._sync_databases(arch_config=install_context.config, aur_supported=install_context.aur_supported,
root_password=root_password, handler=handler)
@@ -2607,7 +2633,7 @@ class ArchManager(SoftwareManager):
def prepare(self, task_manager: TaskManager, root_password: str, internet_available: bool):
arch_config = read_config(update_file=True)
- if internet_available:
+ if internet_available and AURIndexUpdater.should_update(arch_config):
self.index_aur = AURIndexUpdater(context=self.context, taskman=task_manager) # must all execute to properly determine the installed packages (even that AUR is disabled)
self.index_aur.start()
@@ -2811,6 +2837,13 @@ class ArchManager(SoftwareManager):
only_int=True,
max_width=max_width,
value=local_config['mirrors_sort_limit'] if isinstance(local_config['mirrors_sort_limit'], int) else ''),
+ TextInputComponent(id_='aur_idx_exp',
+ label=self.i18n['arch.config.aur_idx_exp'] + ' (AUR)',
+ tooltip=self.i18n['arch.config.aur_idx_exp.tip'],
+ max_width=max_width,
+ only_int=True,
+ capitalize_label=False,
+ value=local_config['aur_idx_exp'] if isinstance(local_config['aur_idx_exp'], int) else ''),
new_select(id_='aur_build_only_chosen',
label=self.i18n['arch.config.aur_build_only_chosen'],
tip=self.i18n['arch.config.aur_build_only_chosen.tip'],
@@ -2868,6 +2901,7 @@ class ArchManager(SoftwareManager):
config['aur_remove_build_dir'] = form_install.get_component('aur_remove_build_dir').get_selected()
config['aur_build_dir'] = form_install.get_component('aur_build_dir').file_path
config['aur_build_only_chosen'] = form_install.get_component('aur_build_only_chosen').get_selected()
+ config['aur_idx_exp'] = form_install.get_component('aur_idx_exp').get_int_value()
config['check_dependency_breakage'] = form_install.get_component('check_dependency_breakage').get_selected()
config['suggest_optdep_uninstall'] = form_install.get_component('suggest_optdep_uninstall').get_selected()
config['suggest_unneeded_uninstall'] = form_install.get_component('suggest_unneeded_uninstall').get_selected()
diff --git a/bauh/gems/arch/resources/locale/ca b/bauh/gems/arch/resources/locale/ca
index 8226144f..88f00e26 100644
--- a/bauh/gems/arch/resources/locale/ca
+++ b/bauh/gems/arch/resources/locale/ca
@@ -47,6 +47,8 @@ arch.config.check_dependency_breakage=Check dependency version breakage
arch.config.check_dependency_breakage.tip=If, during the verification of upgrade requirements, specific versions of dependencies must also be checked. Example: package A depends on version 1.0 of B.
arch.config.edit_aur_pkgbuild=Edit PKGBUILD (AUR)
arch.config.edit_aur_pkgbuild.tip=If the PKGBUILD file of an AUR package should be displayed for editing before its installation/upgrade/downgrade
+arch.config.aur_idx_exp=Index expiration
+arch.config.aur_idx_exp.tip=It defines the period (in minutes) for the AUR index stored in disc to be considered valid during the initialization process. Use 0 so that it is always updated.
arch.config.mirrors_sort_limit=Mirrors sort limit
arch.config.mirrors_sort_limit.tip=Defines the maximum number of mirrors that will be used for speed sorting. Use 0 for no limit or leave it blank to disable sorting.
arch.config.optimize=optimize
diff --git a/bauh/gems/arch/resources/locale/de b/bauh/gems/arch/resources/locale/de
index 1121223a..afb28a48 100644
--- a/bauh/gems/arch/resources/locale/de
+++ b/bauh/gems/arch/resources/locale/de
@@ -47,6 +47,8 @@ arch.config.check_dependency_breakage=Check dependency version breakage
arch.config.check_dependency_breakage.tip=If, during the verification of upgrade requirements, specific versions of dependencies must also be checked. Example: package A depends on version 1.0 of B.
arch.config.edit_aur_pkgbuild=Edit PKGBUILD (AUR)
arch.config.edit_aur_pkgbuild.tip=If the PKGBUILD file of an AUR package should be displayed for editing before its installation/upgrade/downgrade
+arch.config.aur_idx_exp=Index expiration
+arch.config.aur_idx_exp.tip=It defines the period (in minutes) for the AUR index stored in disc to be considered valid during the initialization process. Use 0 so that it is always updated.
arch.config.mirrors_sort_limit=Mirrors sort limit
arch.config.mirrors_sort_limit.tip=Defines the maximum number of mirrors that will be used for speed sorting. Use 0 for no limit or leave it blank to disable sorting.
arch.config.optimize=optimize
diff --git a/bauh/gems/arch/resources/locale/en b/bauh/gems/arch/resources/locale/en
index 5b14be01..298d1721 100644
--- a/bauh/gems/arch/resources/locale/en
+++ b/bauh/gems/arch/resources/locale/en
@@ -47,6 +47,8 @@ arch.config.check_dependency_breakage=Check dependency version breakage
arch.config.check_dependency_breakage.tip=If, during the verification of upgrade requirements, specific versions of dependencies must also be checked. Example: package A depends on version 1.0 of B.
arch.config.edit_aur_pkgbuild=Edit PKGBUILD (AUR)
arch.config.edit_aur_pkgbuild.tip=If the PKGBUILD file of an AUR package should be displayed for editing before its installation/upgrade/downgrade
+arch.config.aur_idx_exp=Index expiration
+arch.config.aur_idx_exp.tip=It defines the period (in minutes) for the AUR index stored in disc to be considered valid during the initialization process. Use 0 so that it is always updated.
arch.config.mirrors_sort_limit=Mirrors sort limit
arch.config.mirrors_sort_limit.tip=Defines the maximum number of mirrors that will be used for speed sorting. Use 0 for no limit or leave it blank to disable sorting.
arch.config.optimize=optimize
diff --git a/bauh/gems/arch/resources/locale/es b/bauh/gems/arch/resources/locale/es
index 5782d4be..b1facb7a 100644
--- a/bauh/gems/arch/resources/locale/es
+++ b/bauh/gems/arch/resources/locale/es
@@ -47,6 +47,8 @@ arch.config.check_dependency_breakage=Verificar rotura de versión de dependenci
arch.config.check_dependency_breakage.tip=Si, durante la verificación de los requisitos de actualización, también se deben verificar versiones específicas de las dependencias. Ejemplo: el paquete A depende de la versión 1.0 de B.
arch.config.edit_aur_pkgbuild=Editar PKGBUILD (AUR)
arch.config.edit_aur_pkgbuild.tip=Si el archivo PKGBUILD de un paquete AUR debe ser exhibido para edición antes de su instalación/actualización/degradación
+arch.config.aur_idx_exp=Expiración del índice
+arch.config.aur_idx_exp.tip=Define el período (en minutos) para que el índice AUR almacenado en el disco se considere válido durante el proceso de inicialización. Utilice 0 para que esté siempre actualizado.
arch.config.mirrors_sort_limit=Límite de ordenación de espejos
arch.config.mirrors_sort_limit.tip=Define el número máximo de espejos que se utilizarán para la ordenación por velocidad. Use 0 para no limitar o déjelo en blanco para deshabilitar la clasificación.
arch.config.optimize=optimizar
diff --git a/bauh/gems/arch/resources/locale/fr b/bauh/gems/arch/resources/locale/fr
index 66703409..0a99e6f0 100644
--- a/bauh/gems/arch/resources/locale/fr
+++ b/bauh/gems/arch/resources/locale/fr
@@ -47,6 +47,8 @@ arch.config.check_dependency_breakage=Vérification pour éviter qu'une version
arch.config.check_dependency_breakage.tip=Si, durant la vérification des prérequis de mise à jour, des versions spécifiques de dépendances doivent aussi être vérifiées. Exemple: paquet A dépend de B version 1.0.
arch.config.edit_aur_pkgbuild=Éditer PKGBUILD (AUR)
arch.config.edit_aur_pkgbuild.tip=Si le fichier PKGBUILD d'un paquet AUR devrait être affiché pour édition avant installation/mise à jour/downgrade
+arch.config.aur_idx_exp=Index expiration
+arch.config.aur_idx_exp.tip=It defines the period (in minutes) for the AUR index stored in disc to be considered valid during the initialization process. Use 0 so that it is always updated.
arch.config.mirrors_sort_limit=Limite de tri des miroirs
arch.config.mirrors_sort_limit.tip=Définit le nombre maximal de miroirs utilisés pour trier vite. 0 pour aucune limite ou vide pour désactiver le tri.
arch.config.optimize=optimizer
diff --git a/bauh/gems/arch/resources/locale/it b/bauh/gems/arch/resources/locale/it
index 40259ec5..145fac24 100644
--- a/bauh/gems/arch/resources/locale/it
+++ b/bauh/gems/arch/resources/locale/it
@@ -47,6 +47,8 @@ arch.config.check_dependency_breakage=Check dependency version breakage
arch.config.check_dependency_breakage.tip=If, during the verification of upgrade requirements, specific versions of dependencies must also be checked. Example: package A depends on version 1.0 of B.
arch.config.edit_aur_pkgbuild=Edit PKGBUILD (AUR)
arch.config.edit_aur_pkgbuild.tip=If the PKGBUILD file of an AUR package should be displayed for editing before its installation/upgrade/downgrade
+arch.config.aur_idx_exp=Index expiration
+arch.config.aur_idx_exp.tip=It defines the period (in minutes) for the AUR index stored in disc to be considered valid during the initialization process. Use 0 so that it is always updated.
arch.config.mirrors_sort_limit=Mirrors sort limit
arch.config.mirrors_sort_limit.tip=Defines the maximum number of mirrors that will be used for speed sorting. Use 0 for no limit or leave it blank to disable sorting.
arch.config.optimize=optimize
diff --git a/bauh/gems/arch/resources/locale/pt b/bauh/gems/arch/resources/locale/pt
index 809d175f..f2f9571d 100644
--- a/bauh/gems/arch/resources/locale/pt
+++ b/bauh/gems/arch/resources/locale/pt
@@ -47,8 +47,10 @@ arch.config.check_dependency_breakage=Verificar quebra de dependência de versã
arch.config.check_dependency_breakage.tip=Se durante a verificação dos requisitos de atualização deve-se verificar também versões específicas de dependências. Exemplo: pacote A depende da versão 1.0 de B.
arch.config.edit_aur_pkgbuild=Editar PKGBUILD (AUR)
arch.config.edit_aur_pkgbuild.tip=Se o arquivo PKGBUILD de um pacote do AUR deve ser exibido para edição antes da instalação/atualização/reversão
+arch.config.aur_idx_exp=Expiração do índice
+arch.config.aur_idx_exp.tip=Define o período (em minutos) em que o índice do AUR armazenado em disco é considerado válido durante a inicialização. Utilize 0 para que ele sempre seja atualizado.
arch.config.mirrors_sort_limit=Limite de ordenação de espelhos
-arch.config.mirrors_sort_limit.tip=Define o número máximo de espelhos que serão utilizados para a ordenação por velocidade. Use 0 para não limitar ou deixe em branco para desabilitar a ordenação.
+arch.config.mirrors_sort_limit.tip=Define o número máximo de espelhos que serão utilizados para a ordenação por velocidade. Utilize 0 para não limitar ou deixe em branco para desabilitar a ordenação.
arch.config.optimize=Otimizar
arch.config.pacman_mthread_download=Download segmentado (repositórios)
arch.config.pacman_mthread_download.tip=Se os pacotes dos repositórios devem baixados através de uma ferramenta que trabalha com segmentação/threads (pode ser mais rápido). pacman-mirrors precisa estar instalado.
diff --git a/bauh/gems/arch/resources/locale/ru b/bauh/gems/arch/resources/locale/ru
index 4eefc357..9062f24b 100644
--- a/bauh/gems/arch/resources/locale/ru
+++ b/bauh/gems/arch/resources/locale/ru
@@ -47,6 +47,8 @@ arch.config.check_dependency_breakage=Check dependency version breakage
arch.config.check_dependency_breakage.tip=If, during the verification of upgrade requirements, specific versions of dependencies must also be checked. Example: package A depends on version 1.0 of B.
arch.config.edit_aur_pkgbuild=Edit PKGBUILD (AUR)
arch.config.edit_aur_pkgbuild.tip=If the PKGBUILD file of an AUR package should be displayed for editing before its installation/upgrade/downgrade
+arch.config.aur_idx_exp=Index expiration
+arch.config.aur_idx_exp.tip=It defines the period (in minutes) for the AUR index stored in disc to be considered valid during the initialization process. Use 0 so that it is always updated.
arch.config.mirrors_sort_limit=Ограничение сортировки зеркал
arch.config.mirrors_sort_limit.tip=Определяет максимальное количество зеркал, которые будут использоваться для сортировки по скорости. Используйте 0 для No limit или оставьте его пустым, чтобы отключить сортировку.
arch.config.optimize=Оптимизация
diff --git a/bauh/gems/arch/resources/locale/tr b/bauh/gems/arch/resources/locale/tr
index 71440d55..553ee200 100644
--- a/bauh/gems/arch/resources/locale/tr
+++ b/bauh/gems/arch/resources/locale/tr
@@ -47,6 +47,8 @@ arch.config.check_dependency_breakage=Check dependency version breakage
arch.config.check_dependency_breakage.tip=If, during the verification of upgrade requirements, specific versions of dependencies must also be checked. Example: package A depends on version 1.0 of B.
arch.config.edit_aur_pkgbuild=Edit PKGBUILD (AUR)
arch.config.edit_aur_pkgbuild.tip=If the PKGBUILD file of an AUR package should be displayed for editing before its installation/upgrade/downgrade
+arch.config.aur_idx_exp=Index expiration
+arch.config.aur_idx_exp.tip=It defines the period (in minutes) for the AUR index stored in disc to be considered valid during the initialization process. Use 0 so that it is always updated.
arch.config.mirrors_sort_limit=Yansı sıralama sınırı
arch.config.mirrors_sort_limit.tip=Hız sıralama için kullanılacak maksimum yansı sayısını tanımlar. Sınırsız olması için 0 kullanın veya sıralamayı devre dışı bırakmak için boş bırakın.
arch.config.optimize=optimize
diff --git a/bauh/gems/arch/worker.py b/bauh/gems/arch/worker.py
index 6a97c1df..63f4ecdc 100644
--- a/bauh/gems/arch/worker.py
+++ b/bauh/gems/arch/worker.py
@@ -4,6 +4,7 @@ import os
import re
import time
import traceback
+from datetime import datetime, timedelta
from pathlib import Path
from threading import Thread
from typing import Optional
@@ -14,8 +15,9 @@ from bauh.api.abstract.context import ApplicationContext
from bauh.api.abstract.handler import TaskManager
from bauh.commons.html import bold
from bauh.commons.system import run_cmd, new_root_subprocess, ProcessHandler
+from bauh.commons.util import datetime_as_milis
from bauh.gems.arch import pacman, disk, CUSTOM_MAKEPKG_FILE, CONFIG_DIR, AUR_INDEX_FILE, get_icon_path, database, \
- mirrors, ARCH_CACHE_PATH, BUILD_DIR
+ mirrors, ARCH_CACHE_PATH, BUILD_DIR, AUR_INDEX_TS_FILE
from bauh.gems.arch.aur import URL_INDEX
from bauh.view.util.translation import I18n
@@ -37,12 +39,40 @@ class AURIndexUpdater(Thread):
self.taskman = taskman
self.task_id = 'index_aur'
+ @staticmethod
+ def should_update(arch_config: dict) -> bool:
+ try:
+ exp_minutes = int(arch_config['aur_idx_exp'])
+ except:
+ traceback.print_exc()
+ return True
+
+ if exp_minutes <= 0:
+ return True
+
+ if not os.path.exists(AUR_INDEX_FILE):
+ return True
+
+ if not os.path.exists(AUR_INDEX_TS_FILE):
+ return True
+
+ with open(AUR_INDEX_TS_FILE) as f:
+ timestamp_str = f.read()
+
+ try:
+ index_timestamp = datetime.fromtimestamp(float(timestamp_str))
+ return (index_timestamp + timedelta(minutes=exp_minutes)) <= datetime.utcnow()
+ except:
+ traceback.print_exc()
+ return True
+
def run(self):
ti = time.time()
self.logger.info('Indexing AUR packages')
self.taskman.register_task(self.task_id, self.i18n['arch.task.aur.index.status'], get_icon_path())
self.taskman.update_progress(self.task_id, 1, self.i18n['arch.task.aur.index.substatus.download'])
try:
+ index_ts = datetime.utcnow().timestamp()
res = self.http_client.get(URL_INDEX)
if res and res.text:
@@ -50,7 +80,8 @@ class AURIndexUpdater(Thread):
self.taskman.update_progress(self.task_id, index_progress,
self.i18n['arch.task.aur.index.substatus.gen_index'])
indexed = 0
- Path(BUILD_DIR).mkdir(parents=True, exist_ok=True)
+
+ Path(os.path.dirname(AUR_INDEX_FILE)).mkdir(parents=True, exist_ok=True)
with open(AUR_INDEX_FILE, 'w+') as f:
lines = res.text.split('\n')
@@ -70,6 +101,9 @@ class AURIndexUpdater(Thread):
perc_count += 1
+ with open(AUR_INDEX_TS_FILE, 'w+') as f:
+ f.write(str(index_ts))
+
self.logger.info('Pre-indexed {} AUR package names at {}'.format(indexed, AUR_INDEX_FILE))
self.taskman.update_progress(self.task_id, 100, None)
diff --git a/bauh/view/qt/components.py b/bauh/view/qt/components.py
index 58861d7c..39823180 100644
--- a/bauh/view/qt/components.py
+++ b/bauh/view/qt/components.py
@@ -491,7 +491,7 @@ class TextInputQt(QGroupBox):
if model.tooltip:
self.text_input.setToolTip(model.tooltip)
- if model.value:
+ if model.value is not None:
self.text_input.setText(model.value)
self.text_input.setCursorPosition(0)
@@ -786,8 +786,8 @@ class FormQt(QGroupBox):
if c.placeholder:
view.setPlaceholderText(c.placeholder)
- if c.value:
- view.setText(str(c.value) if c.value else '')
+ if c.value is not None:
+ view.setText(str(c.value))
view.setCursorPosition(0)
if c.read_only: