Skip to content

Commit

Permalink
Fix build_id not changed when a file is renamed
Browse files Browse the repository at this point in the history
Shiv has to take filenames into account when calculating build_id, otherwise if the only change in the zipapp is a rename - this will result in the same build_id, and the newly built zipapp won't be unpacked if there's already an older version in the cache. This is obviously an issue for zipapps which contain data files (i.e. not referenced by code directly); for example, this may break "preamble" if the preamble file is renamed but the rest of the archive remains the same - if the zipapp has already been executed, the new preamble file will be called but an old cache folder will be used, where the file is called differently.
  • Loading branch information
f3flight authored and lorencarvalho committed Sep 13, 2022
1 parent b5591fd commit 26b23af
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/shiv/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ def create_archive(

# update the contents hash
contents_hash.update(data)
# take filenames into account as well - build_id should change if a file is moved or renamed
contents_hash.update(str(path.relative_to(source)).encode())

arcname = str(site_packages / path.relative_to(source))

Expand Down

0 comments on commit 26b23af

Please sign in to comment.