Improve reconstruct_eclasses error handling.
authorZac Medico <zmedico@gentoo.org>
Wed, 25 Oct 2006 02:36:00 +0000 (02:36 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 25 Oct 2006 02:36:00 +0000 (02:36 -0000)
svn path=/main/trunk/; revision=4814

pym/cache/template.py

index 547490e29443612501cbfe0a3759d9f245b1e93c..1e3c9abe8ab861e90816468c025858dec1ab28f4 100644 (file)
@@ -170,16 +170,15 @@ def reconstruct_eclasses(cpv, eclass_string):
        if len(eclasses) % 2 != 0 and len(eclasses) % 3 != 0:
                raise cache_errors.CacheCorruption(cpv, "_eclasses_ was of invalid len %i" % len(eclasses))
        d={}
-       has_paths = False
        try:
-               long(eclasses[1])
+               if eclasses[1].isdigit():
+                       for x in xrange(0, len(eclasses), 2):
+                               d[eclasses[x]] = long(eclasses[x + 1])
+               else:
+                       # The old format contains paths that will be discarded.
+                       for x in xrange(0, len(eclasses), 3):
+                               d[eclasses[x]] = long(eclasses[x + 2])
        except ValueError:
-               has_paths = True
-       if has_paths:
-               for x in range(0, len(eclasses), 3):
-                       d[eclasses[x]] = long(eclasses[x + 2])
-       else:
-               for x in range(0, len(eclasses), 2):
-                       d[eclasses[x]] = long(eclasses[x + 1])
+               raise cache_errors.CacheCorruption(cpv, "_eclasses_ mtime conversion to long failed")
        del eclasses
        return d