Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Lib/tarfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1616,14 +1616,19 @@ def _apply_pax_info(self, pax_headers, encoding, errors):
"""Replace fields with supplemental information from a previous
pax extended or global header.
"""
real_size_updated = False
for keyword, value in pax_headers.items():
if keyword == "GNU.sparse.name":
setattr(self, "path", value)
elif keyword == "GNU.sparse.size":
setattr(self, "size", int(value))
real_size_updated = True
elif keyword == "GNU.sparse.realsize":
setattr(self, "size", int(value))
real_size_updated = True
elif keyword in PAX_FIELDS:
if keyword == "size" and real_size_updated:
continue
if keyword in PAX_NUMBER_FIELDS:
try:
value = PAX_NUMBER_FIELDS[keyword](value)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Always set ``TarInfo.size`` to the real file size for sparse files.
Loading