diff options
author | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2022-06-14 16:19:05 -0400 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2022-06-14 16:19:05 -0400 |
commit | bfe5df6694c8115fa8402943b125c6e47c8eec08 (patch) | |
tree | 086626ca30d2e7908b393c8914b3dd0ce35e634a | |
parent | 02d2e9d0d2f0f97badca57b89b4681e839c353e0 (diff) | |
download | b4-bfe5df6694c8115fa8402943b125c6e47c8eec08.tar.gz |
Remove unnecessary lookup when /all/ is used in midmask
On lore.kernel.org we provide a unified index of all mailing lists in
/all/, which removes the need to perform a redirect lookup when querying
by message-id. However, some public-inbox instances may not have that,
so we still need to be able to fall back to that redirect lookup. Adapt
a patch from Rob Herring to support both situations.
Link: https://lore.kernel.org/tools/20220225031135.4136158-1-robh@kernel.org/
Suggested-by: Rob Herring <robh@kernel.org>
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r-- | b4/__init__.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/b4/__init__.py b/b4/__init__.py index 0d506bb..85a0978 100644 --- a/b4/__init__.py +++ b/b4/__init__.py @@ -100,7 +100,7 @@ DEFAULT_TRAILER_ORDER = '*' LOREADDR = 'https://lore.kernel.org' DEFAULT_CONFIG = { - 'midmask': LOREADDR + '/r/%s', + 'midmask': LOREADDR + '/all/%s', 'linkmask': LOREADDR + '/r/%s', 'trailer-order': DEFAULT_TRAILER_ORDER, 'listid-preference': '*.feeds.kernel.org,*.linux.dev,*.kernel.org,*', @@ -2235,6 +2235,9 @@ def get_pi_thread_by_url(t_mbx_url, nocache=False): logger.critical('Grabbing thread from %s', t_mbx_url.split('://')[1]) session = get_requests_session() resp = session.get(t_mbx_url) + if resp.status_code == 404: + logger.critical('That message-id is not known.') + return None if resp.status_code != 200: logger.critical('Server returned an error: %s', resp.status_code) return None @@ -2263,12 +2266,18 @@ def get_pi_thread_by_url(t_mbx_url, nocache=False): def get_pi_thread_by_msgid(msgid, useproject=None, nocache=False, onlymsgids: Optional[set] = None): qmsgid = urllib.parse.quote_plus(msgid) config = get_main_config() - # Grab the head from lore, to see where we are redirected - midmask = config['midmask'] % qmsgid - loc = urllib.parse.urlparse(midmask) + loc = urllib.parse.urlparse(config['midmask']) + # The public-inbox instance may provide a unified index at /all/. + # In fact, /all/ naming is arbitrary, but for now we are going to + # hardcode it to lore.kernel.org settings and maybe make it configurable + # in the future, if necessary. + if loc.path.startswith('/all/'): + useproject = 'all' if useproject: projurl = '%s://%s/%s' % (loc.scheme, loc.netloc, useproject) else: + # Grab the head from lore, to see where we are redirected + midmask = config['midmask'] % qmsgid logger.info('Looking up %s', midmask) session = get_requests_session() resp = session.head(midmask) |