Fix recursive_finder so it doesn't re-read files multiple times
This closes a corner case where recursive_finder could read a file multiple times.
This commit is contained in:
parent
14b3ae1120
commit
55503004ec
1 changed files with 16 additions and 14 deletions
|
@ -607,7 +607,6 @@ def recursive_finder(name, data, py_module_names, py_module_cache, zf):
|
||||||
py_module_name = py_module_name[:-1]
|
py_module_name = py_module_name[:-1]
|
||||||
|
|
||||||
# If not already processed then we've got work to do
|
# If not already processed then we've got work to do
|
||||||
if py_module_name not in py_module_names:
|
|
||||||
# If not in the cache, then read the file into the cache
|
# If not in the cache, then read the file into the cache
|
||||||
# We already have a file handle for the module open so it makes
|
# We already have a file handle for the module open so it makes
|
||||||
# sense to read it now
|
# sense to read it now
|
||||||
|
@ -616,14 +615,17 @@ def recursive_finder(name, data, py_module_names, py_module_cache, zf):
|
||||||
# Read the __init__.py instead of the module file as this is
|
# Read the __init__.py instead of the module file as this is
|
||||||
# a python package
|
# a python package
|
||||||
normalized_name = py_module_name + ('__init__',)
|
normalized_name = py_module_name + ('__init__',)
|
||||||
|
if normalized_name not in py_module_names:
|
||||||
normalized_path = os.path.join(os.path.join(module_info[1], '__init__.py'))
|
normalized_path = os.path.join(os.path.join(module_info[1], '__init__.py'))
|
||||||
normalized_data = _slurp(normalized_path)
|
normalized_data = _slurp(normalized_path)
|
||||||
|
py_module_cache[normalized_name] = (normalized_data, normalized_path)
|
||||||
|
normalized_modules.add(normalized_name)
|
||||||
else:
|
else:
|
||||||
normalized_name = py_module_name
|
normalized_name = py_module_name
|
||||||
|
if normalized_name not in py_module_names:
|
||||||
normalized_path = module_info[1]
|
normalized_path = module_info[1]
|
||||||
normalized_data = module_info[0].read()
|
normalized_data = module_info[0].read()
|
||||||
module_info[0].close()
|
module_info[0].close()
|
||||||
|
|
||||||
py_module_cache[normalized_name] = (normalized_data, normalized_path)
|
py_module_cache[normalized_name] = (normalized_data, normalized_path)
|
||||||
normalized_modules.add(normalized_name)
|
normalized_modules.add(normalized_name)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue