summaryrefslogtreecommitdiff
path: root/Lib/tarfile.py
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2005-10-20 04:50:13 +0000
committerNeal Norwitz <nnorwitz@gmail.com>2005-10-20 04:50:13 +0000
commit4880578bec0a27b85151da26dbad0e3227b343c9 (patch)
tree511650c231e568a678555da2d95a71ddecad55c7 /Lib/tarfile.py
parent25f8a7369e6997b9bd2fe658da84a67471520fd9 (diff)
downloadcpython-4880578bec0a27b85151da26dbad0e3227b343c9.tar.gz
Fix SF bug # 1330039, patch # 1331635 from Lars Gustaebel (tarfile maintainer)
Problem: if two files are assigned the same inode number by the filesystem, the second one will be added as a hardlink to the first, which means that the content will be lost. The patched code checks if the file's st_nlink is greater 1. So only for files that actually have several links pointing to them hardlinks will be created, which is what GNU tar does. Will backport.
Diffstat (limited to 'Lib/tarfile.py')
-rw-r--r--Lib/tarfile.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index 2f2197184c..c86248c1a4 100644
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -1150,7 +1150,8 @@ class TarFile(object):
stmd = statres.st_mode
if stat.S_ISREG(stmd):
inode = (statres.st_ino, statres.st_dev)
- if inode in self.inodes and not self.dereference:
+ if not self.dereference and \
+ statres.st_nlink > 1 and inode in self.inodes:
# Is it a hardlink to an already
# archived file?
type = LNKTYPE