Skip to content

Commit

Permalink
Deterministically sort files from os.walk in file packager [NFC] (#17550
Browse files Browse the repository at this point in the history
)

This ensures a consistent order even across OSes.
  • Loading branch information
wolfv authored Aug 9, 2022
1 parent 5c4b167 commit 90139f8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tools/file_packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,10 @@ def was_seen(name):
seen.add(name)
return False

# The files are sorted by the dstpath to make the order of files reproducible
# across file systems / operating systems (os.walk does not produce the same
# file order on different file systems / operating systems)
data_files = sorted(data_files, key=lambda file_: file_.dstpath)
data_files = [file_ for file_ in data_files if not was_seen(file_.dstpath)]

if AV_WORKAROUND:
Expand Down

0 comments on commit 90139f8

Please sign in to comment.