summaryrefslogtreecommitdiffstats
path: root/pym/cache
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2006-10-24 07:20:12 +0000
committerZac Medico <zmedico@gentoo.org>2006-10-24 07:20:12 +0000
commit630ad8983eaa46ff1962454be001befb2120d1b9 (patch)
tree601430115faa0ff2dcda718566952f0f6028fce5 /pym/cache
parentc8162735497d172dfdc1db7164cc8ed8b074943d (diff)
downloadportage-630ad8983eaa46ff1962454be001befb2120d1b9.tar.gz
portage-630ad8983eaa46ff1962454be001befb2120d1b9.tar.bz2
portage-630ad8983eaa46ff1962454be001befb2120d1b9.zip
Remove paths from _eclasses_ serialization in the cache. This makes the mtimes of the eclasses the only thing that distinguishes them, but the probablility of collision is negligible. This same _eclasses_ format will be used to serialize eclass mtimes in cache that is distributed via the rsync mirrors. The deserialization code can handle mixtures of both the old and new formats.
svn path=/main/trunk/; revision=4807
Diffstat (limited to 'pym/cache')
-rw-r--r--pym/cache/template.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/pym/cache/template.py b/pym/cache/template.py
index ff2bbeacf..547490e29 100644
--- a/pym/cache/template.py
+++ b/pym/cache/template.py
@@ -157,7 +157,8 @@ class database(object):
def serialize_eclasses(eclass_dict):
"""takes a dict, returns a string representing said dict"""
- return "\t".join(["%s\t%s\t%s" % (k, v[0], str(v[1])) for k,v in eclass_dict.items()])
+ return "\t".join(["%s\t%s" % (k, str(v)) \
+ for k, v in eclass_dict.iteritems()])
def reconstruct_eclasses(cpv, eclass_string):
"""returns a dict when handed a string generated by serialize_eclasses"""
@@ -165,10 +166,20 @@ def reconstruct_eclasses(cpv, eclass_string):
if eclasses == [""]:
# occasionally this occurs in the fs backends. they suck.
return {}
- if len(eclasses) % 3 != 0:
+
+ if len(eclasses) % 2 != 0 and len(eclasses) % 3 != 0:
raise cache_errors.CacheCorruption(cpv, "_eclasses_ was of invalid len %i" % len(eclasses))
d={}
- for x in range(0, len(eclasses), 3):
- d[eclasses[x]] = (eclasses[x + 1], long(eclasses[x + 2]))
+ has_paths = False
+ try:
+ long(eclasses[1])
+ 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])
del eclasses
return d