syncpackage: Catch exceptions cleanly, simply skipping to the next package (erring on the side of caution) if there is an error doing the download (LP: #1943286).

This commit is contained in:
Simon Quigley 2025-03-04 13:42:35 -06:00
parent 2e550ceff2
commit ba3f0511f9
2 changed files with 9 additions and 2 deletions

3
debian/changelog vendored
View File

@ -16,6 +16,9 @@ ubuntu-dev-tools (0.206) UNRELEASED; urgency=medium
* syncpackage: s/syncblacklist/syncblocklist/g * syncpackage: s/syncblacklist/syncblocklist/g
* syncpackage: Cache the sync blocklist in-memory, so it's not fetched * syncpackage: Cache the sync blocklist in-memory, so it's not fetched
multiple times when syncing more than one package. multiple times when syncing more than one package.
* syncpackage: Catch exceptions cleanly, simply skipping to the next
package (erring on the side of caution) if there is an error doing the
download (LP: #1943286).
-- Simon Quigley <tsimonq2@debian.org> Tue, 04 Mar 2025 13:04:30 -0600 -- Simon Quigley <tsimonq2@debian.org> Tue, 04 Mar 2025 13:04:30 -0600

View File

@ -459,8 +459,12 @@ def is_blocklisted(query):
global cached_sync_blocklist global cached_sync_blocklist
if not cached_sync_blocklist: if not cached_sync_blocklist:
url = "https://ubuntu-archive-team.ubuntu.com/sync-blocklist.txt" url = "https://ubuntu-archive-team.ubuntu.com/sync-blocklist.txt"
with urllib.request.urlopen(url) as f: try:
cached_sync_blocklist = f.read().decode("utf-8") with urllib.request.urlopen(url) as f:
cached_sync_blocklist = f.read().decode("utf-8")
except:
print("WARNING: unable to download the sync blocklist. Erring on the side of caution.")
return ("ALWAYS", "INTERNAL ERROR: Unable to fetch sync blocklist")
applicable_lines = [] applicable_lines = []
for line in cached_sync_blocklist.splitlines(): for line in cached_sync_blocklist.splitlines():