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 027991384B4 for ; Tue, 29 Dec 2015 16:42:20 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 9216F21C004; Tue, 29 Dec 2015 16:42:19 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id EE6AA21C004 for ; Tue, 29 Dec 2015 16:42:18 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id EF67334068A for ; Tue, 29 Dec 2015 16:42:16 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 7041CC86 for ; Tue, 29 Dec 2015 16:42:14 +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: <1451407197.6c09ab7d6c6b2ffcf7e2641874167b0bff12ff91.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/cache/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/cache/template.py X-VCS-Directories: pym/portage/cache/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 6c09ab7d6c6b2ffcf7e2641874167b0bff12ff91 X-VCS-Branch: master Date: Tue, 29 Dec 2015 16:42:14 +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: 77ee928c-c9ef-4951-982e-222bcb2a33d8 X-Archives-Hash: 3ac1d001416fad6660b4f05faba3d227 commit: 6c09ab7d6c6b2ffcf7e2641874167b0bff12ff91 Author: Zac Medico gentoo org> AuthorDate: Thu Dec 24 11:08:54 2015 +0000 Commit: Zac Medico gentoo org> CommitDate: Tue Dec 29 16:39:57 2015 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=6c09ab7d template.database.__getitem__: allow missing mtime (bug 568934) Fix __getitem__ to allow missing mtime when a suitable alternative (such as md5) is available. Fixes: 669d11bd8af5 ("flat_hash: enable md5 validation for /var/cache/edb/dep (bug 568934)") Acked-by: Alexander Berntsen gentoo.org> pym/portage/cache/template.py | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/pym/portage/cache/template.py b/pym/portage/cache/template.py index a942b36..a7c6de0 100644 --- a/pym/portage/cache/template.py +++ b/pym/portage/cache/template.py @@ -46,12 +46,13 @@ class database(object): self.commit() self.updates = 0 d=self._getitem(cpv) - if self.serialize_eclasses and "_eclasses_" in d: - try: - chf_types = self.chf_types - except AttributeError: - chf_types = (self.validation_chf,) + try: + chf_types = self.chf_types + except AttributeError: + chf_types = (self.validation_chf,) + + if self.serialize_eclasses and "_eclasses_" in d: for chf_type in chf_types: try: d["_eclasses_"] = reconstruct_eclasses(cpv, d["_eclasses_"], @@ -69,16 +70,23 @@ class database(object): # to omit it in comparisons between cache entries like # those that egencache uses to avoid redundant writes. d.pop("INHERITED", None) + + mtime_required = not any(d.get('_%s_' % x) + for x in chf_types if x != 'mtime') + mtime = d.get('_mtime_') - if mtime is None: - raise cache_errors.CacheCorruption(cpv, - '_mtime_ field is missing') - try: - mtime = long(mtime) - except ValueError: - raise cache_errors.CacheCorruption(cpv, - '_mtime_ conversion to long failed: %s' % (mtime,)) - d['_mtime_'] = mtime + if not mtime: + if mtime_required: + raise cache_errors.CacheCorruption(cpv, + '_mtime_ field is missing') + d.pop('_mtime_', None) + else: + try: + mtime = long(mtime) + except ValueError: + raise cache_errors.CacheCorruption(cpv, + '_mtime_ conversion to long failed: %s' % (mtime,)) + d['_mtime_'] = mtime return d def _getitem(self, cpv):