mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
[3.13] gh-75989: TarFile.extractall and TarFile.extract now overwrite symlinks when extracting hardlinks (GH-137316) (GH-139771)
(cherry picked from commit 481d5b5455)
Co-authored-by: Alexander Urieles <aeurielesn@users.noreply.github.com>
This commit is contained in:
parent
69a34938f8
commit
abe6f529ff
3 changed files with 57 additions and 0 deletions
|
|
@ -2660,6 +2660,9 @@ def makelink_with_filter(self, tarinfo, targetpath,
|
|||
return
|
||||
else:
|
||||
if os.path.exists(tarinfo._link_target):
|
||||
if os.path.lexists(targetpath):
|
||||
# Avoid FileExistsError on following os.link.
|
||||
os.unlink(targetpath)
|
||||
os.link(tarinfo._link_target, targetpath)
|
||||
return
|
||||
except symlink_exception:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue