From: Ɓukasz Langa Date: Sat, 11 Jun 2016 23:42:36 +0000 (-0700) Subject: Issue #27194: superfluous truncate calls in tarfile.py slow down extraction X-Git-Tag: v3.5.2rc1~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e7f27481a895fb73408e523202345fcd9355b00c;p=thirdparty%2FPython%2Fcpython.git Issue #27194: superfluous truncate calls in tarfile.py slow down extraction Patch by Jason Fried. --- diff --git a/Lib/tarfile.py b/Lib/tarfile.py index 86e1cf9b89c5..721f9d7f9180 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 diff --git a/Misc/ACKS b/Misc/ACKS index 001373b9406b..be303e0e5019 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -458,6 +458,7 @@ Stefan Franke Martin Franklin Kent Frazier Bruce Frederiksen +Jason Fried Robin Friedrich Bradley Froehle Ivan Frohne