Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/cache/
Date: Tue, 29 Dec 2015 16:42:20
Message-Id: 1451407197.6c09ab7d6c6b2ffcf7e2641874167b0bff12ff91.zmedico@gentoo
1 commit: 6c09ab7d6c6b2ffcf7e2641874167b0bff12ff91
2 Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
3 AuthorDate: Thu Dec 24 11:08:54 2015 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Tue Dec 29 16:39:57 2015 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=6c09ab7d
7
8 template.database.__getitem__: allow missing mtime (bug 568934)
9
10 Fix __getitem__ to allow missing mtime when a suitable alternative
11 (such as md5) is available.
12
13 Fixes: 669d11bd8af5 ("flat_hash: enable md5 validation for /var/cache/edb/dep (bug 568934)")
14 Acked-by: Alexander Berntsen <bernalex <AT> gentoo.org>
15
16 pym/portage/cache/template.py | 36 ++++++++++++++++++++++--------------
17 1 file changed, 22 insertions(+), 14 deletions(-)
18
19 diff --git a/pym/portage/cache/template.py b/pym/portage/cache/template.py
20 index a942b36..a7c6de0 100644
21 --- a/pym/portage/cache/template.py
22 +++ b/pym/portage/cache/template.py
23 @@ -46,12 +46,13 @@ class database(object):
24 self.commit()
25 self.updates = 0
26 d=self._getitem(cpv)
27 - if self.serialize_eclasses and "_eclasses_" in d:
28 - try:
29 - chf_types = self.chf_types
30 - except AttributeError:
31 - chf_types = (self.validation_chf,)
32
33 + try:
34 + chf_types = self.chf_types
35 + except AttributeError:
36 + chf_types = (self.validation_chf,)
37 +
38 + if self.serialize_eclasses and "_eclasses_" in d:
39 for chf_type in chf_types:
40 try:
41 d["_eclasses_"] = reconstruct_eclasses(cpv, d["_eclasses_"],
42 @@ -69,16 +70,23 @@ class database(object):
43 # to omit it in comparisons between cache entries like
44 # those that egencache uses to avoid redundant writes.
45 d.pop("INHERITED", None)
46 +
47 + mtime_required = not any(d.get('_%s_' % x)
48 + for x in chf_types if x != 'mtime')
49 +
50 mtime = d.get('_mtime_')
51 - if mtime is None:
52 - raise cache_errors.CacheCorruption(cpv,
53 - '_mtime_ field is missing')
54 - try:
55 - mtime = long(mtime)
56 - except ValueError:
57 - raise cache_errors.CacheCorruption(cpv,
58 - '_mtime_ conversion to long failed: %s' % (mtime,))
59 - d['_mtime_'] = mtime
60 + if not mtime:
61 + if mtime_required:
62 + raise cache_errors.CacheCorruption(cpv,
63 + '_mtime_ field is missing')
64 + d.pop('_mtime_', None)
65 + else:
66 + try:
67 + mtime = long(mtime)
68 + except ValueError:
69 + raise cache_errors.CacheCorruption(cpv,
70 + '_mtime_ conversion to long failed: %s' % (mtime,))
71 + d['_mtime_'] = mtime
72 return d
73
74 def _getitem(self, cpv):