Skip to content

Commit 563a745

Browse files
committed
Attempt to catch decompression errors and proceed without decompression.
1 parent 244a66e commit 563a745

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

sc2reader/__init__.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,16 +115,24 @@ def make_replay(self, replay_file, **options):
115115
archive = mpyq.MPQArchive(replay_file, listfile=False)
116116
except KeyboardInterrupt: raise
117117
except:
118-
raise #exceptions.MPQError("Unable to construct the MPQArchive")
118+
raise exceptions.MPQError("Unable to construct the MPQArchive")
119119

120120
# These files are configured for either full or partial parsing
121121
for file in options.files:
122122

123123
# To wrap mpyq exceptions we have to do this try hack.
124124
try:
125-
# We are currently assuming that the message file is always compressed
125+
# Handle the tampering with the message.events file that some sites do
126126
if file == 'replay.message.events':
127-
filedata = archive.read_file(file, force_decompress=True)
127+
try:
128+
filedata = archive.read_file(file, force_decompress=True)
129+
except IndexError as e:
130+
# Catch decompression errors
131+
print str(e)
132+
if str(e) == "string index out of range":
133+
filedata = archive.read_file(file, force_decompress=False)
134+
else:
135+
raise
128136
else:
129137
filedata = archive.read_file(file)
130138
except KeyboardInterrupt: raise

0 commit comments

Comments
 (0)