[Python-checkins] python/dist/src/Lib tarfile.py, 1.21.2.5, 1.21.2.6

nnorwitz@users.sourceforge.net nnorwitz at users.sourceforge.net
Thu Oct 20 06:56:12 CEST 2005


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25202/Lib

Modified Files:
      Tag: release24-maint
	tarfile.py 
Log Message:
Backport:
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.


Index: tarfile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/tarfile.py,v
retrieving revision 1.21.2.5
retrieving revision 1.21.2.6
diff -u -d -r1.21.2.5 -r1.21.2.6
--- tarfile.py	27 Aug 2005 10:08:21 -0000	1.21.2.5
+++ tarfile.py	20 Oct 2005 04:56:09 -0000	1.21.2.6
@@ -1103,7 +1103,8 @@
         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



More information about the Python-checkins mailing list