commit: 6c09ab7d6c6b2ffcf7e2641874167b0bff12ff91
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 24 11:08:54 2015 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> 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 <bernalex <AT> 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):