summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2018-01-09 15:43:03 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2018-01-09 17:48:06 +0000
commit0a6d74cd036f2aeffafc053cbd1ce3fc60ced16c (patch)
treeb2cdfbd1ac85721a468dab156124bd21fe9f1e8a
parent37562b10f15de2f31f7d78ed8d82100c4fac8cf1 (diff)
downloadbuildstream-sam/local-source-cachekey-fix.tar.gz
utils.py: Sort the results of list_relative_paths()sam/local-source-cachekey-fix
This fixes a serious issue in the 'local' source plugin: this source type generates its unique key from the list of filenames it pulls in from the local machine, but the list would be unsorted so cache keys would randomly vary. Rather than fix this in the specific plugin, we chose to fix the public utility function that generates the list of filenames to reduce the chance of this mistake being repeated elsewhere.
-rw-r--r--buildstream/utils.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/buildstream/utils.py b/buildstream/utils.py
index 2b6c4517c..e8b15bc48 100644
--- a/buildstream/utils.py
+++ b/buildstream/utils.py
@@ -104,6 +104,8 @@ def list_relative_paths(directory):
Relative filenames in `directory`
"""
for (dirpath, dirnames, filenames) in os.walk(directory):
+ dirnames.sort()
+ filenames.sort()
relpath = os.path.relpath(dirpath, directory)