summaryrefslogtreecommitdiffstats
path: root/Lib/tarfile.py
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2004-07-20 22:07:44 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2004-07-20 22:07:44 (GMT)
commita4f651a2ae9288df1006c6f5a1ca922a5120dde1 (patch)
treecc1782fa721e12738be7c5273ec25d958781ef3a /Lib/tarfile.py
parent0662f8a5eaa19f7eed6978eed1af32563359fb93 (diff)
downloadcpython-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.py7
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),