From b83f9d844096e85313837d01406253e7e60dbc0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Moreira?= Date: Tue, 14 Jan 2020 19:31:24 -0300 Subject: [PATCH] [fix][aur] not pre-downloading some source files --- CHANGELOG.md | 1 + bauh/gems/arch/controller.py | 5 +++-- bauh/view/core/downloader.py | 10 +++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 93ac4595..6cdc46ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - AUR: - not treating **makedepends' as a list during dependency checking ( **anbox-git** installation was crashing ) - not considering the package name itself as *provided** during dependency checking ( **anbox-git** installation was crashing ) + - not pre-downloading some source files ( e.g: from **anbox-image** ) ## [0.8.1] 2020-01-14 ### Features: diff --git a/bauh/gems/arch/controller.py b/bauh/gems/arch/controller.py index e2de8b8d..e2fa65c3 100644 --- a/bauh/gems/arch/controller.py +++ b/bauh/gems/arch/controller.py @@ -36,7 +36,8 @@ URL_SRC_INFO = 'https://aur.archlinux.org/cgit/aur.git/plain/.SRCINFO?h=' RE_SPLIT_VERSION = re.compile(r'(=|>|<)') SOURCE_FIELDS = ('source', 'source_x86_64') -RE_PRE_DOWNLOADABLE_FILES = re.compile(r'(https?|ftp)://.+\.\w+[^gpg|git]$') +RE_PRE_DOWNLOAD_WL_PROTOCOLS = re.compile(r'^(.+::)?(https?|ftp)://.+') +RE_PRE_DOWNLOAD_BL_EXT = re.compile(r'.+\.(git|gpg)$') SEARCH_OPTIMIZED_MAP = { 'google chrome': 'google-chrome', @@ -424,7 +425,7 @@ class ArchManager(SoftwareManager): continue else: for f in srcinfo[attr]: - if RE_PRE_DOWNLOADABLE_FILES.findall(f): + if RE_PRE_DOWNLOAD_WL_PROTOCOLS.match(f) and not RE_PRE_DOWNLOAD_BL_EXT.match(f): pre_download_files.append(f) if pre_download_files: diff --git a/bauh/view/core/downloader.py b/bauh/view/core/downloader.py index 2b5f0a48..34d2f220 100644 --- a/bauh/view/core/downloader.py +++ b/bauh/view/core/downloader.py @@ -1,5 +1,6 @@ import logging import os +import re import time import traceback @@ -10,6 +11,7 @@ from bauh.commons.html import bold from bauh.commons.system import run_cmd, new_subprocess, ProcessHandler, SystemProcess, SimpleProcess from bauh.view.util.translation import I18n +RE_HAS_EXTENSION = re.compile(r'.+\.\w+$') class AdaptableFileDownloader(FileDownloader): @@ -90,7 +92,13 @@ class AdaptableFileDownloader(FileDownloader): downloader = 'wget' file_size = self.http_client.get_content_length(file_url) - msg = bold('[{}] ').format(downloader) + self.i18n['downloading'] + ' ' + bold(file_url.split('/')[-1]) + (' ( {} )'.format(file_size) if file_size else '') + + name = file_url.split('/')[-1] + + if output_path and not RE_HAS_EXTENSION.match(name) and RE_HAS_EXTENSION.match(output_path): + name = output_path.split('/')[-1] + + msg = bold('[{}] ').format(downloader) + self.i18n['downloading'] + ' ' + bold(name) + (' ( {} )'.format(file_size) if file_size else '') if watcher: watcher.change_substatus(msg)