Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Sort directories and files to ensure they are always processed in the same order #177

Merged
merged 1 commit into from
Aug 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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