Gentoo Archives: gentoo-portage-dev

From: W-Mark Kubacki <wmark@×××××××××.de>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH] Portage to write a compressed copy of 'Packages' index file
Date: Thu, 09 Aug 2012 00:05:44
Message-Id: 20120808215650.GA21702@3-0.hurrikane.de
In Reply to: Re: [gentoo-portage-dev] [PATCH] Portage to write a compressed copy of 'Packages' index file by Zac Medico
1 On Wed, Aug 08, 2012 at 02:00:23PM -0700, Zac Medico wrote:
2 > On 08/08/2012 11:35 AM, W-Mark Kubacki wrote:
3 > > In order to re-use 'atomic_ofstream' usage of 'codecs.zlib_codec'
4 > > has been considered and discarded, because 'GzipFile' yields
5 > > smaller files. (According to Mark's tests 62% smaller.)
6 >
7 > I've fixed it to use an atomic_ofstream as GzipFile's fileobj argument:
8 >
9 > http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=e95a07267c7f642fdca2aca346ab4c12f46748bb
10
11 I've noticed the differences between my initial patch and your commit.
12 Thank you!
13
14 Indeed, GzipFile not closing the underlying 'fileobj' makes things ugly.
15 Your previous and now detached commit (where 'os.pid' has been appended
16 to the file name and, after having been closed, the file was renamed)
17 made me wonder whether modification times would be preserved. Well,
18 that's an obsolete though now.
19
20 The example usage with Apache httpd is not complete. Some conditions are
21 missing. I have no Apache httpd at hand, but that's what I gather from
22 the documentation:
23
24 RewriteCond %{HTTP:Accept-encoding} gzip
25 RewriteCond %{REQUEST_FILENAME}\.gz -s
26 RewriteRule ^(.*)/Packages$ $1/Packages.gz
27 [QSA,T=text/plain,E=no-gzip:1,L]
28 <FilesMatch "Packages\.gz$">
29 Header set Content-Encoding gzip
30 </FilesMatch>
31
32 'Packages' served as 'text/plain' will prevent browsers from downloading
33 that file like, say, zip files. And, one of my next patches will
34 introduce the 'Accept' HTTP header which could come in handy in future
35 extensions – and content-negotiation on server-side; 'text/plain+diff'
36 anyone? ;-)
37
38 --
39 Grüße, Mark