diff --git a/CB/Core.py b/CB/Core.py index 42fc46f..00324df 100644 --- a/CB/Core.py +++ b/CB/Core.py @@ -368,6 +368,7 @@ def bulk_check_checksum_callback(self, result): self.checksumCache[result[0]] = result[1] def bulk_check_checksum(self, addons, pbar): + self.checksumCache = {} with Pool(processes=min(60, os.cpu_count() or 1)) as pool: workers = [] for addon in addons: diff --git a/CB/CurseForge.py b/CB/CurseForge.py index a3351e5..7d828ec 100644 --- a/CB/CurseForge.py +++ b/CB/CurseForge.py @@ -13,8 +13,11 @@ def __init__(self, url, project, checkcache, clienttype, allowdev): if project in checkcache: self.payload = checkcache[project] else: - self.payload = requests.get(f'https://addons-ecs.forgesvc.net/api/v2/addon/{project}', - headers=HEADERS, timeout=5) + try: + self.payload = requests.get(f'https://addons-ecs.forgesvc.net/api/v2/addon/{project}', + headers=HEADERS, timeout=5) + except (requests.exceptions.ConnectionError, requests.exceptions.Timeout): + raise RuntimeError(f'{url}\nCurseForge API failed to respond.') if self.payload.status_code == 404 or self.payload.status_code == 500: raise RuntimeError(f'{url}\nThis might be a temporary issue with CurseForge API or the project was ' f'removed/renamed. In this case, uninstall it (and reinstall if it still exists) ' diff --git a/CB/GitHub.py b/CB/GitHub.py index b6c05fc..69c1c34 100644 --- a/CB/GitHub.py +++ b/CB/GitHub.py @@ -10,7 +10,10 @@ class GitHubAddon: @retry() def __init__(self, url, clienttype): project = url.replace('https://github.com/', '') - self.payload = requests.get(f'https://api.github.com/repos/{project}/releases', headers=HEADERS, timeout=5) + try: + self.payload = requests.get(f'https://api.github.com/repos/{project}/releases', headers=HEADERS, timeout=5) + except (requests.exceptions.ConnectionError, requests.exceptions.Timeout): + raise RuntimeError(f'{project}\nGitHub API failed to respond.') if self.payload.status_code == 404: raise RuntimeError(url) else: @@ -72,8 +75,11 @@ def install(self, path): class GitHubAddonRaw: @retry() def __init__(self, project, branch, targetdirs): - self.payload = requests.get(f'https://api.github.com/repos/{project}/branches/{branch}', - headers=HEADERS, timeout=5) + try: + self.payload = requests.get(f'https://api.github.com/repos/{project}/branches/{branch}', + headers=HEADERS, timeout=5) + except (requests.exceptions.ConnectionError, requests.exceptions.Timeout): + raise RuntimeError(f'{project}\nGitHub API failed to respond.') if self.payload.status_code == 404: raise RuntimeError(f'{project}\nTarget branch don\'t exist.') else: diff --git a/CB/GitLab.py b/CB/GitLab.py index 5106364..f39ca53 100644 --- a/CB/GitLab.py +++ b/CB/GitLab.py @@ -8,8 +8,11 @@ class GitLabAddon: @retry() def __init__(self, name, projectid, path, branch): - self.payload = requests.get(f'https://git.tukui.org/api/v4/projects/{projectid}/repository/branches/{branch}', - headers=HEADERS, timeout=5) + try: + self.payload = requests.get(f'https://git.tukui.org/api/v4/projects/{projectid}/repository/branches/' + f'{branch}', headers=HEADERS, timeout=5) + except (requests.exceptions.ConnectionError, requests.exceptions.Timeout): + raise RuntimeError(f'{name}\nTukui GitLab API failed to respond.') if self.payload.status_code == 404: raise RuntimeError(name) else: diff --git a/CB/Tukui.py b/CB/Tukui.py index 3c522fd..063258b 100644 --- a/CB/Tukui.py +++ b/CB/Tukui.py @@ -10,8 +10,11 @@ class TukuiAddon: @retry() def __init__(self, url, checkcache, special=None): if special: - self.payload = requests.get(f'https://www.tukui.org/api.php?ui={special}', - headers=HEADERS, timeout=5).json() + try: + self.payload = requests.get(f'https://www.tukui.org/api.php?ui={special}', + headers=HEADERS, timeout=5).json() + except (requests.exceptions.ConnectionError, requests.exceptions.Timeout): + raise RuntimeError(f'{url}\nTukui API failed to respond.') else: project = re.findall(r'\d+', url)[0] for addon in checkcache: diff --git a/CB/WoWInterface.py b/CB/WoWInterface.py index 6e87886..271a8a3 100644 --- a/CB/WoWInterface.py +++ b/CB/WoWInterface.py @@ -13,8 +13,11 @@ def __init__(self, url, checkcache): if project in checkcache: self.payload = checkcache[project] else: - self.payload = requests.get(f'https://api.mmoui.com/v3/game/WOW/filedetails/{project}.json', - headers=HEADERS, timeout=5).json() + try: + self.payload = requests.get(f'https://api.mmoui.com/v3/game/WOW/filedetails/{project}.json', + headers=HEADERS, timeout=5).json() + except (requests.exceptions.ConnectionError, requests.exceptions.Timeout): + raise RuntimeError(f'{url}\nWoWInterface API failed to respond.') if 'ERROR' in self.payload: raise RuntimeError(f'{url}\nThis might be a temporary error or this project is not supported ' f'by WoWInterface API.') diff --git a/CurseBreaker.py b/CurseBreaker.py index 0cb3f7b..613b49c 100644 --- a/CurseBreaker.py +++ b/CurseBreaker.py @@ -488,10 +488,6 @@ def c_uninstall(self, args): def c_update(self, args, addline=False, update=True, force=False, provider=False, reversecompact=False): compact = not self.core.config['CompactMode'] if reversecompact else self.core.config['CompactMode'] - if len(self.core.cfCache) > 0 or len(self.core.wowiCache) > 0: - self.core.cfCache = {} - self.core.wowiCache = {} - self.core.checksumCache = {} if args: addons = self.parse_args(args) compacted = -1 @@ -505,7 +501,10 @@ def c_update(self, args, addline=False, update=True, force=False, provider=False auto_refresh=False, console=None if self.headless else self.console) as progress: task = progress.add_task('', total=len(addons)) if not args: - self.core.bulk_check(addons) + try: + self.core.bulk_check(addons) + except RuntimeError: + pass self.core.bulk_check_checksum(addons, progress) while not progress.finished: for addon in addons: @@ -724,7 +723,10 @@ def c_show(self, args): if args.startswith('dependencies'): addons = sorted(list(filter(lambda k: k['URL'].startswith('https://www.curseforge.com/wow/addons/'), self.core.config['Addons'])), key=lambda k: k['Name'].lower()) - self.core.bulk_check(addons) + try: + self.core.bulk_check(addons) + except RuntimeError: + pass for addon in addons: dependencies = DependenciesParser(self.core) name, _, _, _, _, _, _, _, _, _, deps, _ = self.core.update_addon(addon['URL'], False, False)