aboutsummaryrefslogtreecommitdiff
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2012-08-08 13:34:15 -0700
committerZac Medico <zmedico@gentoo.org>2012-08-08 13:51:45 -0700
commite95a07267c7f642fdca2aca346ab4c12f46748bb (patch)
tree02a44b86895fe2fb2643b5e264f83717f9f1142b /pym
parentPortage writes a compressed copy of 'Packages' index file. (diff)
downloadportage-e95a07267c7f642fdca2aca346ab4c12f46748bb.tar.gz
portage-e95a07267c7f642fdca2aca346ab4c12f46748bb.tar.bz2
portage-e95a07267c7f642fdca2aca346ab4c12f46748bb.zip
bintree.inject(): write Packages.gz atomically
Diffstat (limited to 'pym')
-rw-r--r--pym/portage/dbapi/bintree.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py
index 77fc0c4ef..8dd7aadd4 100644
--- a/pym/portage/dbapi/bintree.py
+++ b/pym/portage/dbapi/bintree.py
@@ -1193,13 +1193,16 @@ class binarytree(object):
atime = mtime = long(pkgindex.header["TIMESTAMP"])
pkgindex_filename = os.path.join(self.pkgdir, "Packages")
- output_files = [(atomic_ofstream(pkgindex_filename, mode="wb"), pkgindex_filename)]
+ output_files = [(atomic_ofstream(pkgindex_filename, mode="wb"), pkgindex_filename, None)]
if "compress-index" in self.settings.features:
gz_fname = pkgindex_filename + ".gz"
- output_files.append((GzipFile(gz_fname, mode="wb"), gz_fname))
- for f, fname in output_files:
+ fileobj = atomic_ofstream(gz_fname, mode="wb")
+ output_files.append((GzipFile(filename='', mode="wb", fileobj=fileobj, mtime=mtime), gz_fname, fileobj))
+ for f, fname, f_close in output_files:
f.write(contents)
f.close()
+ if f_close is not None:
+ f_close.close()
# some seconds might have elapsed since TIMESTAMP
os.utime(fname, (atime, mtime))
finally: