Skip to content

Commit

Permalink
Sort directories and files to ensure they are always processed in the…
Browse files Browse the repository at this point in the history
… same order
  • Loading branch information
pdecat committed Jul 15, 2021
1 parent 185858d commit 42a64d1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions package.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ def list_files(top_path, log=None):
results = []

for root, dirs, files in os.walk(top_path, followlinks=True):
# Sort directories and files to ensure they are always processed in the same order
dirs.sort()
files.sort()
for file_name in files:
file_path = os.path.join(root, file_name)
relative_path = os.path.relpath(file_path, top_path)
Expand Down Expand Up @@ -211,6 +214,9 @@ def yesno_bool(val):

def emit_dir_content(base_dir):
for root, dirs, files in os.walk(base_dir, followlinks=True):
# Sort directories and files to ensure they are always processed in the same order
dirs.sort()
files.sort()
if root != base_dir:
yield os.path.normpath(root)
for name in files:
Expand Down Expand Up @@ -596,6 +602,9 @@ def emit_file(fpath, opath):
yield path
else:
for root, dirs, files in os.walk(path, followlinks=True):
# Sort directories and files to ensure they are always processed in the same order
dirs.sort()
files.sort()
o, d = norm_path(path, root)
# log.info('od: %s %s', o, d)
if root != path:
Expand Down

0 comments on commit 42a64d1

Please sign in to comment.