pg.ddx.io pgsql-www@postgresql.org mailing list archive
help / color / mirror / Atom feed[PATCH] Disambiguate mbox download files
4+ messages / 3 participants
[nested] [flat]
* [PATCH] Disambiguate mbox download files
@ 2026-06-24 15:11 Kevin <me@kevinrocker.com>
2026-07-22 13:50 ` Re: [PATCH] Disambiguate mbox download files Magnus Hagander <magnus@hagander.net>
0 siblings, 1 reply; 4+ messages in thread
From: Kevin @ 2026-06-24 15:11 UTC (permalink / raw)
To: pgsql-www@lists.postgresql.org
The mailing list monthly archives were all downloading with the same filename, just "psql-hackers.mbox", which turned into "psql-hackers(1).mbox", "psql-hackers(2).mbox", etc.
This patch sets the `Content-Disposition` header to a filename that includes the list and the year/month.
Attachments:
0001-Serve-per-month-mbox-downloads-with-a-unique-filenam.patch (text/x-patch, 2.2K) download
From c9a2d14ed784a439cfdad0a232a611a436c77940 Mon Sep 17 00:00:00 2001
From: Kevin Rocker <me@kevinrocker.com>
Date: Wed, 24 Jun 2026 15:25:21 +0200
Subject: [PATCH] Serve per-month mbox downloads with a unique filename
The monthly mbox download view streamed responses with only a
Content-type header and no Content-Disposition, so browsers derived the
saved filename from the URL. Every month of a list shares the same name
bar the extension, so downloading several months produced
pgsql-hackers.mbox, pgsql-hackers(1).mbox, ... rather than distinct,
identifiable files.
Add an optional filename argument to _build_mbox() that emits a
Content-Disposition: attachment header, and have the per-month mbox()
view pass listname.YYYYMM.mbox (matching the existing URL scheme), so
each month downloads under a distinct, descriptive name.
---
django/archives/mailarchives/views.py | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/django/archives/mailarchives/views.py b/django/archives/mailarchives/views.py
index 5d7e321..fbc9731 100644
--- a/django/archives/mailarchives/views.py
+++ b/django/archives/mailarchives/views.py
@@ -676,7 +676,7 @@ def message_raw(request, msgid):
return r
-def _build_mbox(query, params, msgid=None):
+def _build_mbox(query, params, msgid=None, filename=None):
connection.ensure_connection()
# Rawmsg is not in the django model, so we have to query it separately
@@ -710,6 +710,8 @@ def _build_mbox(query, params, msgid=None):
r = StreamingHttpResponse(_message_stream(firstmsg))
r['Content-type'] = 'application/mbox'
+ if filename:
+ r['Content-Disposition'] = 'attachment; filename="%s"' % filename
return r
@@ -755,7 +757,11 @@ def mbox(request, listname, listname2, mboxyear, mboxmonth):
else:
# Just return the whole thing
query = query.replace('%%%', '')
- return _build_mbox(query, params)
+ # Set a per-list, per-month filename (matching the URL scheme,
+ # listname.YYYYMM) so downloads don't all collide on the same name.
+ return _build_mbox(
+ query, params,
+ filename='%s.%04d%02d.mbox' % (listname, mboxyear, mboxmonth))
@transaction.atomic
--
2.54.0
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [PATCH] Disambiguate mbox download files
2026-06-24 15:11 [PATCH] Disambiguate mbox download files Kevin <me@kevinrocker.com>
@ 2026-07-22 13:50 ` Magnus Hagander <magnus@hagander.net>
2026-07-31 14:51 ` Re: [PATCH] Disambiguate mbox download files Kevin Rocker <me@kevinrocker.com>
0 siblings, 1 reply; 4+ messages in thread
From: Magnus Hagander @ 2026-07-22 13:50 UTC (permalink / raw)
To: Kevin <me@kevinrocker.com>; +Cc: pgsql-www@lists.postgresql.org
On Thu, 25 Jun 2026 at 16:13, Kevin <me@kevinrocker.com> wrote:
> The mailing list monthly archives were all downloading with the same
> filename, just "psql-hackers.mbox", which turned into
> "psql-hackers(1).mbox", "psql-hackers(2).mbox", etc.
>
> This patch sets the `Content-Disposition` header to a filename that
> includes the list and the year/month.
>
I like this idea and the patch looks good. However, is there a reason not
to also do this for the other code path calling _build_mbox()? If nothing
else, for consistency?
--
Magnus Hagander
Me: https://www.hagander.net/ <http://www.hagander.net/;
Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/;
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [PATCH] Disambiguate mbox download files
2026-06-24 15:11 [PATCH] Disambiguate mbox download files Kevin <me@kevinrocker.com>
2026-07-22 13:50 ` Re: [PATCH] Disambiguate mbox download files Magnus Hagander <magnus@hagander.net>
@ 2026-07-31 14:51 ` Kevin Rocker <me@kevinrocker.com>
2026-08-29 07:58 ` Re: [PATCH] Disambiguate mbox download files Magnus Hagander <magnus@hagander.net>
0 siblings, 1 reply; 4+ messages in thread
From: Kevin Rocker @ 2026-07-31 14:51 UTC (permalink / raw)
To: Magnus Hagander <magnus@hagander.net>; +Cc: pgsql-www@lists.postgresql.org
Makes sense to me. The per-thread path already had a good filename, but was missing the file extension, so more benefits than just consistency.
On Wed, Jul 22, 2026, at 3:50 PM, Magnus Hagander wrote:
>
>
> On Thu, 25 Jun 2026 at 16:13, Kevin <me@kevinrocker.com> wrote:
>> __
>> The mailing list monthly archives were all downloading with the same filename, just "psql-hackers.mbox", which turned into "psql-hackers(1).mbox", "psql-hackers(2).mbox", etc.
>>
>> This patch sets the `Content-Disposition` header to a filename that includes the list and the year/month.
>
> I like this idea and the patch looks good. However, is there a reason not to also do this for the other code path calling _build_mbox()? If nothing else, for consistency?
>
> --
> Magnus Hagander
> Me: https://www.hagander.net/
> Work: https://www.redpill-linpro.com/
Attachments:
0002-Serve-per-thread-mbox-downloads-with-an-explicit-fil.patch (text/x-patch, 896B) download
From 68b61f4742bb03971ad43c86355a0dc52b4fa78a Mon Sep 17 00:00:00 2001
From: Kevin Rocker <me@kevinrocker.com>
Date: Fri, 31 Jul 2026 16:27:25 +0200
Subject: [PATCH] Serve per-thread mbox downloads with an explicit filename
Make the per-thread view consistent with the monthly downloads. Properly
set the .mbox extension/header and use the message-id as the filename.
---
django/archives/mailarchives/views.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/django/archives/mailarchives/views.py b/django/archives/mailarchives/views.py
index fbc9731..ad1d238 100644
--- a/django/archives/mailarchives/views.py
+++ b/django/archives/mailarchives/views.py
@@ -728,7 +728,7 @@ def message_mbox(request, msgid):
{
'thread': msg.threadid,
},
- msgid)
+ msgid, filename='%s.mbox' % quote(msgid, safe=''))
@csrf_exempt
--
2.54.0
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: [PATCH] Disambiguate mbox download files
2026-06-24 15:11 [PATCH] Disambiguate mbox download files Kevin <me@kevinrocker.com>
2026-07-22 13:50 ` Re: [PATCH] Disambiguate mbox download files Magnus Hagander <magnus@hagander.net>
2026-07-31 14:51 ` Re: [PATCH] Disambiguate mbox download files Kevin Rocker <me@kevinrocker.com>
@ 2026-08-29 07:58 ` Magnus Hagander <magnus@hagander.net>
0 siblings, 0 replies; 4+ messages in thread
From: Magnus Hagander @ 2026-08-29 07:58 UTC (permalink / raw)
To: Kevin Rocker <me@kevinrocker.com>; +Cc: pgsql-www@lists.postgresql.org
Hi!
Looks good! Applied and pushed, thanks!
//Magnus
On Fri, 31 Jul 2026 at 16:52, Kevin Rocker <me@kevinrocker.com> wrote:
> Makes sense to me. The per-thread path already had a good filename, but
> was missing the file extension, so more benefits than just consistency.
>
> On Wed, Jul 22, 2026, at 3:50 PM, Magnus Hagander wrote:
>
>
>
> On Thu, 25 Jun 2026 at 16:13, Kevin <me@kevinrocker.com> wrote:
>
>
> The mailing list monthly archives were all downloading with the same
> filename, just "psql-hackers.mbox", which turned into
> "psql-hackers(1).mbox", "psql-hackers(2).mbox", etc.
>
> This patch sets the `Content-Disposition` header to a filename that
> includes the list and the year/month.
>
>
> I like this idea and the patch looks good. However, is there a reason not
> to also do this for the other code path calling _build_mbox()? If nothing
> else, for consistency?
>
> --
> Magnus Hagander
> Me: https://www.hagander.net/ <http://www.hagander.net/;
> Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/;
>
>
>
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2026-08-29 07:58 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-06-24 15:11 [PATCH] Disambiguate mbox download files Kevin <me@kevinrocker.com>
2026-07-22 13:50 ` Magnus Hagander <magnus@hagander.net>
2026-07-31 14:51 ` Kevin Rocker <me@kevinrocker.com>
2026-08-29 07:58 ` Magnus Hagander <magnus@hagander.net>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox