From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 0FF1E13800E for ; Wed, 8 Aug 2012 20:34:51 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 1F5D3E05ED; Wed, 8 Aug 2012 20:34:28 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id DC86DE05ED for ; Wed, 8 Aug 2012 20:34:27 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 3AF591B4024 for ; Wed, 8 Aug 2012 20:34:27 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id E506EE5439 for ; Wed, 8 Aug 2012 20:34:25 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1344458055.e5233e3c56a3be2db78c0806afabb1c5b7b96bc8.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/dbapi/bintree.py X-VCS-Directories: pym/portage/dbapi/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: e5233e3c56a3be2db78c0806afabb1c5b7b96bc8 X-VCS-Branch: master Date: Wed, 8 Aug 2012 20:34:25 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: e528e17f-15db-4c01-a20c-a2ceaa0cb3f3 X-Archives-Hash: 9ef54e8ebf242d056276fbfea5ea2782 commit: e5233e3c56a3be2db78c0806afabb1c5b7b96bc8 Author: Zac Medico gentoo org> AuthorDate: Wed Aug 8 20:34:15 2012 +0000 Commit: Zac Medico gentoo org> CommitDate: Wed Aug 8 20:34:15 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=e5233e3c bintree.inject(): write Packages.gz atomically --- pym/portage/dbapi/bintree.py | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index 77fc0c4..2872e3b 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -1193,15 +1193,18 @@ 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: + tmp_fname = "%s.%s" % (gz_fname, os.getpid()) + output_files.append((GzipFile(tmp_fname, mode="wb"), tmp_fname, gz_fname)) + for f, fname, fname_rename in output_files: f.write(contents) f.close() # some seconds might have elapsed since TIMESTAMP os.utime(fname, (atime, mtime)) + if fname_rename is not None: + os.rename(fname, fname_rename) finally: if pkgindex_lock: unlockfile(pkgindex_lock)