Issue #27194: superfluous truncate calls in tarfile.py slow down extraction

Patch by Jason Fried.
This commit is contained in:
Łukasz Langa 2016-06-11 16:42:36 -07:00
parent b5ad54990f
commit e7f27481a8
2 changed files with 3 additions and 2 deletions

View File

@ -2150,10 +2150,10 @@ class TarFile(object):
for offset, size in tarinfo.sparse:
target.seek(offset)
copyfileobj(source, target, size, ReadError)
else:
copyfileobj(source, target, tarinfo.size, ReadError)
target.seek(tarinfo.size)
target.truncate()
else:
copyfileobj(source, target, tarinfo.size, ReadError)
def makeunknown(self, tarinfo, targetpath):
"""Make a file from a TarInfo object with an unknown type

View File

@ -458,6 +458,7 @@ Stefan Franke
Martin Franklin
Kent Frazier
Bruce Frederiksen
Jason Fried
Robin Friedrich
Bradley Froehle
Ivan Frohne