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
if actual_synchronous!=synchronous:
raise cache_errors.InitializationError(self.__class__,"actual synchronous = "+actual_synchronous+" does does not match requested value of "+synchronous)
- def __getitem__(self, cpv):
+ def _getitem(self, cpv):
cursor = self._db_cursor
cursor.execute("select * from %s where %s=%s" % \
(self._db_table["packages"]["table_name"],
d[k]=str(d[k]) # convert unicode strings to normal
except UnicodeEncodeError, e:
pass #writemsg("%s: %s\n" % (cpv, str(e)))
- if "_eclasses_" in d:
- d["_eclasses_"] = reconstruct_eclasses(cpv, d["_eclasses_"])
- else:
- d["_eclasses_"] = {}
for x in self._known_keys:
d.setdefault(x,'')
return d
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):
except (KeyError, cache_errors.CacheError):
pass
else:
- try:
- if long(trg["_mtime_"]) == long(entry["_mtime_"]) and \
- eclass_cache.is_eclass_data_valid(trg["_eclasses_"]) and \
- set(trg["_eclasses_"]) == set(entry["_eclasses_"]):
- write_it = False
- except cache_errors.CacheError:
- pass
+ if trg['_mtime_'] == entry['_mtime_'] and \
+ eclass_cache.is_eclass_data_valid(trg['_eclasses_']) and \
+ set(trg['_eclasses_']) == set(entry['_eclasses_']):
+ write_it = False
for d in (entry, trg):
if d is not None and d.get('EAPI') in ('', '0'):
for auxdb in auxdbs:
try:
metadata = auxdb[cpv]
- eapi = metadata.get("EAPI","").strip()
- if not eapi:
- eapi = "0"
- if eapi.startswith("-") and eapi_is_supported(eapi[1:]):
- pass
- elif emtime != int(metadata.get("_mtime_", 0)):
- pass
- elif len(metadata.get("_eclasses_", [])) > 0:
- if self.eclassdb.is_eclass_data_valid(
- metadata["_eclasses_"]):
- doregen = False
- else:
- doregen = False
except KeyError:
pass
except CacheError:
del auxdb[cpv]
except KeyError:
pass
+ else:
+ eapi = metadata.get('EAPI', '').strip()
+ if not eapi:
+ eapi = '0'
+ if not (eapi[:1] == '-' and eapi_is_supported(eapi[1:])) and \
+ emtime == metadata['_mtime_'] and \
+ self.eclassdb.is_eclass_data_valid(metadata['_eclasses_']):
+ doregen = False
+
if not doregen:
break