mirror of https://github.com/docker/docker-py.git
Skip entirely excluded directories when handling dockerignore.
This is pure optimization to not recurse into directories when there are no chances any file will be included. Signed-off-by: mefyl <quentin.hocquet@docker.com>
This commit is contained in:
parent
bb3ad64060
commit
3b464f983e
|
@ -91,6 +91,10 @@ def walk(root, patterns, default=True):
|
|||
matched = default if hit is None else hit
|
||||
sub = list(filter(lambda p: p[1], sub))
|
||||
if os.path.isdir(cur):
|
||||
# Entirely skip directories if there are no chance any subfile will
|
||||
# be included.
|
||||
if all(not p[0] for p in sub) and not matched:
|
||||
continue
|
||||
children = False
|
||||
for r in (os.path.join(f, p) for p in walk(cur, sub, matched)):
|
||||
yield r
|
||||
|
|
Loading…
Reference in New Issue