fix(tree): script copies refresh by content

Size and mtime miss a change that keeps the size and looks older than the
stale tree copy; the copy now compares the bytes.
This commit is contained in:
rpone authored and Sharky Wang committed 2026-11-02 00:05:45 +08:00
1 parent c96b299756
commit a4419c8af7
1 file changed
+3 -1
+3 -1
View File
@@ -35,7 +35,9 @@ def _copy_scripts(source, destination):
target = destination / relative
if target.is_symlink():
target.unlink()
if target.exists() and target.stat().st_size == path.stat().st_size and target.stat().st_mtime >= path.stat().st_mtime:
# Content, not size and mtime: a pure move of code keeps the size, and a checkout can make
# the source look older than a stale tree copy.
if target.exists() and target.read_bytes() == path.read_bytes():
continue
target.parent.mkdir(parents=True, exist_ok=True)
shutil.copy2(path, target)