diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2004-07-20 22:07:44 +0000 |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2004-07-20 22:07:44 +0000 |
commit | 476987ec43862cf8c546498ae63f4ccae3e5c3dd (patch) | |
tree | cc7fcd73ce85d99beb2502170e914ed28ea758f7 /Lib/tarfile.py | |
parent | 57fa1747ec424e4571d547b882dae54184c3e9cf (diff) | |
download | cpython-476987ec43862cf8c546498ae63f4ccae3e5c3dd.tar.gz |
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 d20107ecd2..077fbee709 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), |