Skip to content

Commit 51ae687

Browse files
committed
First force decompression, then try it normally.
This is because an under reported block size will cause mpyq to successfully return a data file that is compressed. Refs #102
1 parent c8a7051 commit 51ae687

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

sc2reader/utils.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -461,18 +461,17 @@ def extract_data_file(data_file, archive):
461461
# attempt decompression. If they under report a compressed
462462
# file might bypass decompression. So do this:
463463
#
464-
# * Attempt to do things normally.
465-
# * Force Decompression and fall back to original exception
466-
# * mpyq doesn't allow you to ignore decompression, it has
467-
# not been a problem yet though.
464+
# * Force a decompression to catch under reporting
465+
# * If that fails, try to process normally
466+
# * mpyq doesn't allow you to skip decompression, so fail
468467
#
469468
# Refs: arkx/mpyq#12, GraylinKim/sc2reader#102
470469
try:
471-
file_data = archive.read_file(data_file)
470+
file_data = archive.read_file(data_file, force_decompress=True)
472471
except Exception as e:
473472
exc_info = sys.exc_info()
474473
try:
475-
file_data = archive.read_file(data_file, force_decompress=True)
474+
file_data = archive.read_file(data_file)
476475
except Exception as e:
477476
# raise the original exception
478477
raise exc_info[1], None, exc_info[2]

0 commit comments

Comments
 (0)