python/dist/src/Lib tarfile.py, 1.21.2.4, 1.21.2.5
Update of /cvsroot/python/python/dist/src/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29574/Lib Modified Files: Tag: release24-maint tarfile.py Log Message: Patch #1168594: set sizes of non-regular files to zero. Fixes #1167128. Index: tarfile.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/tarfile.py,v retrieving revision 1.21.2.4 retrieving revision 1.21.2.5 diff -u -d -r1.21.2.4 -r1.21.2.5 --- tarfile.py 24 Aug 2005 06:44:55 -0000 1.21.2.4 +++ tarfile.py 27 Aug 2005 10:08:21 -0000 1.21.2.5 @@ -1132,17 +1132,16 @@ # Fill the TarInfo object with all # information we can get. - tarinfo.name = arcname - tarinfo.mode = stmd - tarinfo.uid = statres.st_uid - tarinfo.gid = statres.st_gid - if stat.S_ISDIR(stmd): - # For a directory, the size must be 0 - tarinfo.size = 0 - else: + tarinfo.name = arcname + tarinfo.mode = stmd + tarinfo.uid = statres.st_uid + tarinfo.gid = statres.st_gid + if stat.S_ISREG(stmd): tarinfo.size = statres.st_size + else: + tarinfo.size = 0L tarinfo.mtime = statres.st_mtime - tarinfo.type = type + tarinfo.type = type tarinfo.linkname = linkname if pwd: try: @@ -1233,16 +1232,15 @@ self.addfile(tarinfo, f) f.close() - if tarinfo.type in (LNKTYPE, SYMTYPE, FIFOTYPE, CHRTYPE, BLKTYPE): - tarinfo.size = 0L - self.addfile(tarinfo) - - if tarinfo.isdir(): + elif tarinfo.isdir(): self.addfile(tarinfo) if recursive: for f in os.listdir(name): self.add(os.path.join(name, f), os.path.join(arcname, f)) + else: + self.addfile(tarinfo) + def addfile(self, tarinfo, fileobj=None): """Add the TarInfo object `tarinfo' to the archive. If `fileobj' is given, tarinfo.size bytes are read from it and added to the archive.
participants (1)
-
loewis@users.sourceforge.net