提交 89d96a07 authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Fixed crash when some old cached keys are present

上级 77223d49
...@@ -230,7 +230,7 @@ def get_module_hash(module_file, key): ...@@ -230,7 +230,7 @@ def get_module_hash(module_file, key):
"ensure this piece of code is still valid (and this " "ensure this piece of code is still valid (and this "
"AssertionError may be removed or modified to accomodate " "AssertionError may be removed or modified to accomodate "
"this change)") "this change)")
assert (c_link_key[0] == 'CLinker.cmodule_key', error_msg) assert c_link_key[0] == 'CLinker.cmodule_key', error_msg
to_hash = [source_hash] to_hash = [source_hash]
for key_element in c_link_key[1:]: for key_element in c_link_key[1:]:
if isinstance(key_element, tuple): if isinstance(key_element, tuple):
...@@ -424,15 +424,15 @@ class ModuleCache(object): ...@@ -424,15 +424,15 @@ class ModuleCache(object):
continue continue
if not isinstance(key_data, KeyData): if not isinstance(key_data, KeyData):
# Backward-compatibility with older cache mechanism # This is some old cache data, that does not fit
# that used single keys with no hash of the # the new cache format. It would be possible to
# compiled file. # update it, but it is not entirely safe since we
key_data = KeyData( # do not know the config options that were used.
keys=set([key_data]), # As a result, we delete it instead (which is also
module_hash=get_module_hash(entry, key_data), # simpler to implement).
key_pkl=key_pkl) debug('Deleting deprecated cache entry', key_pkl)
debug("Updating cache key to new format", key_pkl) _rmtree(root, ignore_nocleanup=True)
key_data.save_pkl() continue
# Find unversioned keys. # Find unversioned keys.
to_del = [key for key in key_data.keys if not key[0]] to_del = [key for key in key_data.keys if not key[0]]
...@@ -740,9 +740,9 @@ class ModuleCache(object): ...@@ -740,9 +740,9 @@ class ModuleCache(object):
self.clear_old() self.clear_old()
self.clear_unversioned() self.clear_unversioned()
def _rmtree(parent): def _rmtree(parent, ignore_nocleanup=False):
try: try:
if not config.nocleanup: if ignore_nocleanup or not config.nocleanup:
shutil.rmtree(parent) shutil.rmtree(parent)
except Exception, e: except Exception, e:
# If parent still exists, mark it for deletion by a future refresh() # If parent still exists, mark it for deletion by a future refresh()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论