syncpackage: Cache the sync blocklist in-memory, so it's not fetched multiple times when syncing more than one package.

This commit is contained in:
Simon Quigley 2025-03-04 13:39:07 -06:00
parent 6c8a5d74bd
commit 2e550ceff2
2 changed files with 24 additions and 19 deletions

2
debian/changelog vendored
View File

@ -14,6 +14,8 @@ ubuntu-dev-tools (0.206) UNRELEASED; urgency=medium
variables (Closes: #725418). variables (Closes: #725418).
* mk-sbuild: default to using UTC for schroots (LP: #2097159). * mk-sbuild: default to using UTC for schroots (LP: #2097159).
* syncpackage: s/syncblacklist/syncblocklist/g * syncpackage: s/syncblacklist/syncblocklist/g
* syncpackage: Cache the sync blocklist in-memory, so it's not fetched
multiple times when syncing more than one package.
-- 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

@ -49,6 +49,7 @@ from ubuntutools.requestsync.mail import get_debian_srcpkg as requestsync_mail_g
from ubuntutools.version import Version from ubuntutools.version import Version
Logger = getLogger() Logger = getLogger()
cached_sync_blocklist = None
def remove_signature(dscname): def remove_signature(dscname):
@ -455,12 +456,14 @@ def is_blocklisted(query):
if diff.status == "Blacklisted always": if diff.status == "Blacklisted always":
blocklisted = "ALWAYS" blocklisted = "ALWAYS"
# Old blocklist: global 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: with urllib.request.urlopen(url) as f:
cached_sync_blocklist = f.read().decode("utf-8")
applicable_lines = [] applicable_lines = []
for line in f: for line in cached_sync_blocklist.splitlines():
line = line.decode("utf-8")
if not line.strip(): if not line.strip():
applicable_lines = [] applicable_lines = []
continue continue