Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(commands/common/_copy_package_resource): if destination exists and files are same, do not overwrite existing files #1528

Merged
merged 3 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/683.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
On Windows, no longer overwrite existing files on upgrade if source and destination are the same
3 changes: 3 additions & 0 deletions src/pipx/commands/common.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import filecmp
import logging
import os
import shlex
Expand Down Expand Up @@ -108,6 +109,8 @@ def _copy_package_resource(dest_dir: Path, path: Path, suffix: str = "") -> None
if not dest.parent.is_dir():
mkdir(dest.parent)
if dest.exists():
if filecmp.cmp(dest, src, shallow=False):
return
logger.warning(f"{hazard} Overwriting file {dest!s} with {src!s}")
safe_unlink(dest)
if src.exists():
Expand Down