For full compatibility with older versions of portage, write the path in the serializ...
authorZac Medico <zmedico@gentoo.org>
Wed, 25 Oct 2006 21:44:04 +0000 (21:44 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 25 Oct 2006 21:44:04 +0000 (21:44 -0000)
svn path=/main/trunk/; revision=4818

pym/cache/template.py
pym/eclass_cache.py

index cce8e30a899612dde526c5c5a1f045dbdb6a9bbe..565e7d2abe0c6190257a9c11220e009de7df41aa 100644 (file)
@@ -164,10 +164,9 @@ def serialize_eclasses(eclass_dict):
        return "\t".join(["%s\t%s" % (k, str(v)) \
                for k, v in eclass_dict.iteritems()])
        """
-       """ This is a variation of the old format that uses a relative path instead
-       of the full path of the eclass.  It should only force a regen in older
-       versions of portage (rather than a traceback)."""
-       return "\t".join(["%s\teclass\t%s" % (k, str(v)) \
+       if not eclass_dict:
+               return ""
+       return "\t".join(["%s\t%s\t%s" % (k, v[0], str(v[1])) \
                for k, v in eclass_dict.iteritems()])
 
 def reconstruct_eclasses(cpv, eclass_string):
@@ -183,11 +182,11 @@ def reconstruct_eclasses(cpv, eclass_string):
        try:
                if eclasses[1].isdigit():
                        for x in xrange(0, len(eclasses), 2):
-                               d[eclasses[x]] = long(eclasses[x + 1])
+                               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])
+                               d[eclasses[x]] = (eclasses[x + 1], long(eclasses[x + 2]))
        except ValueError:
                raise cache_errors.CacheCorruption(cpv, "_eclasses_ mtime conversion to long failed")
        del eclasses
index 904e63261d21de39bb0b765175707a6826bfede1..6b4f87cd62b63a5e27a4ea8c6a88cead7faa431f 100644 (file)
@@ -50,14 +50,19 @@ class cache:
                                except OSError:
                                        continue
                                ys=y[:-eclass_len]
-                               self.eclasses[ys] = long(mtime)
+                               self.eclasses[ys] = (x, long(mtime))
                                self._eclass_locations[ys] = x
        
        def is_eclass_data_valid(self, ec_dict):
                if not isinstance(ec_dict, dict):
                        return False
                for eclass, mtime in ec_dict.iteritems():
-                       if eclass not in self.eclasses or mtime != self.eclasses[eclass]:
+                       cached_data = self.eclasses.get(eclass, None)
+                       """ Only use the mtime for validation since the probability of a
+                       collision is small and, depending on the cache implementation, the
+                       path may not be specified (cache from rsync mirrors, for example).
+                       """
+                       if cached_data is None or mtime != cached_data[1]:
                                return False
 
                return True