summaryrefslogtreecommitdiffstats
path: root/Lib/tarfile.py
diff options
context:
space:
mode:
authorŁukasz Langa <lukasz@langa.pl>2016-06-11 23:42:36 (GMT)
committerŁukasz Langa <lukasz@langa.pl>2016-06-11 23:42:36 (GMT)
commite7f27481a895fb73408e523202345fcd9355b00c (patch)
treee3c747f8584a0e188ead6556f0553ccb295f8164 /Lib/tarfile.py
parentb5ad54990fc74fe043c91d2a005c7c32c931bc5d (diff)
downloadcpython-e7f27481a895fb73408e523202345fcd9355b00c.zip
cpython-e7f27481a895fb73408e523202345fcd9355b00c.tar.gz
cpython-e7f27481a895fb73408e523202345fcd9355b00c.tar.bz2
Issue #27194: superfluous truncate calls in tarfile.py slow down extraction
Patch by Jason Fried.
Diffstat (limited to 'Lib/tarfile.py')
-rwxr-xr-xLib/tarfile.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index 86e1cf9..721f9d7 100755
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -2150,10 +2150,10 @@ class TarFile(object):
for offset, size in tarinfo.sparse:
target.seek(offset)
copyfileobj(source, target, size, ReadError)
+ target.seek(tarinfo.size)
+ target.truncate()
else:
copyfileobj(source, target, tarinfo.size, ReadError)
- target.seek(tarinfo.size)
- target.truncate()
def makeunknown(self, tarinfo, targetpath):
"""Make a file from a TarInfo object with an unknown type