]> granicus.if.org Git - python/commitdiff
Issue #27194: superfluous truncate calls in tarfile.py slow down extraction
authorŁukasz Langa <lukasz@langa.pl>
Sat, 11 Jun 2016 23:42:36 +0000 (16:42 -0700)
committerŁukasz Langa <lukasz@langa.pl>
Sat, 11 Jun 2016 23:42:36 +0000 (16:42 -0700)
Patch by Jason Fried.

Lib/tarfile.py
Misc/ACKS

index 86e1cf9b89c5c3f97678b6f09a7b90fdc13d1f95..721f9d7f9180316cbb1c90ea23135b3785adfec9 100755 (executable)
@@ -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
index 001373b9406b5b1cd59b42c5ac236ff0b6d9f350..be303e0e501967daba99dd23460063da792e5074 100644 (file)
--- 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