Commit 2a69d9ac authored by hannosch's avatar hannosch

Introduce a cache for the expensive `buildout._dir_hash` function.


git-svn-id: http://svn.zope.org/repos/main/zc.buildout/trunk@120884 62d5b8a3-27da-0310-9561-8e5933582275
parent b68f587e
...@@ -4,6 +4,8 @@ Change History ...@@ -4,6 +4,8 @@ Change History
1.5.3 (unreleased) 1.5.3 (unreleased)
================== ==================
- Introduce a cache for the expensive `buildout._dir_hash` function.
- Remove duplicate path from script's sys.path setup. - Remove duplicate path from script's sys.path setup.
- changed broken dash S check to pass the configuration options - changed broken dash S check to pass the configuration options
......
...@@ -1467,7 +1467,11 @@ def _open(base, filename, seen, dl_options, override, downloaded): ...@@ -1467,7 +1467,11 @@ def _open(base, filename, seen, dl_options, override, downloaded):
ignore_directories = '.svn', 'CVS' ignore_directories = '.svn', 'CVS'
_dir_hashes = {}
def _dir_hash(dir): def _dir_hash(dir):
dir_hash = _dir_hashes.get(dir, None)
if dir_hash is not None:
return dir_hash
hash = md5() hash = md5()
for (dirpath, dirnames, filenames) in os.walk(dir): for (dirpath, dirnames, filenames) in os.walk(dir):
dirnames[:] = [n for n in dirnames if n not in ignore_directories] dirnames[:] = [n for n in dirnames if n not in ignore_directories]
...@@ -1479,7 +1483,8 @@ def _dir_hash(dir): ...@@ -1479,7 +1483,8 @@ def _dir_hash(dir):
hash.update(' '.join(filenames)) hash.update(' '.join(filenames))
for name in filenames: for name in filenames:
hash.update(open(os.path.join(dirpath, name)).read()) hash.update(open(os.path.join(dirpath, name)).read())
return hash.digest().encode('base64').strip() _dir_hashes[dir] = dir_hash = hash.digest().encode('base64').strip()
return dir_hash
def _dists_sig(dists): def _dists_sig(dists):
result = [] result = []
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment