From 42a64d12ca1b8e29fb9c4ce821d23a5bf31728db Mon Sep 17 00:00:00 2001 From: Patrick Decat Date: Thu, 15 Jul 2021 13:01:24 +0200 Subject: [PATCH] Sort directories and files to ensure they are always processed in the same order --- package.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/package.py b/package.py index 98613118..e1d46c98 100644 --- a/package.py +++ b/package.py @@ -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) @@ -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: @@ -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: