summaryrefslogtreecommitdiffstats
path: root/pym/portage/cache/template.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-03-01 06:25:07 +0000
committerZac Medico <zmedico@gentoo.org>2009-03-01 06:25:07 +0000
commit90766d70c76c562af20cb4554bb0dab38a1b0abf (patch)
tree53f8ac70473f85d58ccd60542d7a528b97d67991 /pym/portage/cache/template.py
parente45e8cd48d195269883b90a30c2fd1724b7fddf0 (diff)
downloadportage-90766d70c76c562af20cb4554bb0dab38a1b0abf.tar.gz
portage-90766d70c76c562af20cb4554bb0dab38a1b0abf.tar.bz2
portage-90766d70c76c562af20cb4554bb0dab38a1b0abf.zip
* Fix portage.cache.template.database.__getitem__() to validate the _mtime_
field and raise a CacheCorruption exception if necessary. * Make _mtime_ and _eclasses_ validation code in portdbapi and mirror_cache() assume that these fields are the correct type (otherwise a CacheCorruption exeception should be raised earlier). * Fix the sqlite module to implement _getitem() so that it properly inherits __getitem__() _mtime_ and _eclasses_ handling. svn path=/main/trunk/; revision=12735
Diffstat (limited to 'pym/portage/cache/template.py')
-rw-r--r--pym/portage/cache/template.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/pym/portage/cache/template.py b/pym/portage/cache/template.py
index 35b9efeff..7fce8ef17 100644
--- a/pym/portage/cache/template.py
+++ b/pym/portage/cache/template.py
@@ -40,6 +40,16 @@ class database(object):
d["_eclasses_"] = reconstruct_eclasses(cpv, d["_eclasses_"])
elif "_eclasses_" not in d:
d["_eclasses_"] = {}
+ 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
return d
def _getitem(self, cpv):