Skip to content

Commit c5ab779

Browse files
authored
fix: Sort directories and files to ensure they are always processed in the same order (#177)
1 parent 9f99b85 commit c5ab779

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

package.py

+9
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ def list_files(top_path, log=None):
140140
results = []
141141

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

212215
def emit_dir_content(base_dir):
213216
for root, dirs, files in os.walk(base_dir, followlinks=True):
217+
# Sort directories and files to ensure they are always processed in the same order
218+
dirs.sort()
219+
files.sort()
214220
if root != base_dir:
215221
yield os.path.normpath(root)
216222
for name in files:
@@ -596,6 +602,9 @@ def emit_file(fpath, opath):
596602
yield path
597603
else:
598604
for root, dirs, files in os.walk(path, followlinks=True):
605+
# Sort directories and files to ensure they are always processed in the same order
606+
dirs.sort()
607+
files.sort()
599608
o, d = norm_path(path, root)
600609
# log.info('od: %s %s', o, d)
601610
if root != path:

0 commit comments

Comments
 (0)