diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2004-07-20 22:07:44 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2004-07-20 22:07:44 (GMT) |
commit | a4f651a2ae9288df1006c6f5a1ca922a5120dde1 (patch) | |
tree | cc1782fa721e12738be7c5273ec25d958781ef3a /Lib/tarfile.py | |
parent | 0662f8a5eaa19f7eed6978eed1af32563359fb93 (diff) | |
download | cpython-a4f651a2ae9288df1006c6f5a1ca922a5120dde1.zip cpython-a4f651a2ae9288df1006c6f5a1ca922a5120dde1.tar.gz cpython-a4f651a2ae9288df1006c6f5a1ca922a5120dde1.tar.bz2 |
SF #857297 and 916874, improve handling of hard links when extracting
Diffstat (limited to 'Lib/tarfile.py')
-rw-r--r-- | Lib/tarfile.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py index d20107e..077fbee 100644 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -1294,6 +1294,10 @@ class TarFile(object): else: tarinfo = self.getmember(member) + # Prepare the link target for makelink(). + if tarinfo.islnk(): + tarinfo._link_target = os.path.join(path, tarinfo.linkname) + try: self._extract_member(tarinfo, os.path.join(path, tarinfo.name)) except EnvironmentError, e: @@ -1466,7 +1470,8 @@ class TarFile(object): if tarinfo.issym(): os.symlink(linkpath, targetpath) else: - os.link(linkpath, targetpath) + # See extract(). + os.link(tarinfo._link_target, targetpath) except AttributeError: if tarinfo.issym(): linkpath = os.path.join(os.path.dirname(tarinfo.name), |