Fix __getitem__ to convert mtime to long, and remove unreachable code
authorZac Medico <zmedico@gentoo.org>
Wed, 11 Mar 2009 06:47:03 +0000 (06:47 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 11 Mar 2009 06:47:03 +0000 (06:47 -0000)
from _parse_data(). (trunk r12776)

svn path=/main/branches/2.1.6/; revision=13020

pym/portage/cache/flat_hash.py

index dda380e1c6be624620598ec1e1ff1583a853b48f..f6bf6d078e774b72563c122e6753f953f3dc89d1 100644 (file)
@@ -33,6 +33,16 @@ class database(fs_template.FsBased):
                                        """Backward compatibility with old cache that uses mtime
                                        mangling."""
                                        d["_mtime_"] = long(os.fstat(myf.fileno()).st_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
                                return d
                        finally:
                                myf.close()
@@ -52,14 +62,6 @@ class database(fs_template.FsBased):
                else:
                        d["_eclasses_"] = {}
                return d
-               
-               for x in self._known_keys:
-                       if x not in d:
-                               d[x] = ''
-
-
-               return d
-
 
        def _setitem(self, cpv, values):
 #              import pdb;pdb.set_trace()