0

world: retry chunk read on OSError too

Closes #1790.

If a chunk fails reading due to an underlying operating system
IO error, we can invoke the retry logic too. No clue what could
cause this to happen beyond hardware faults.

Also lower the sleep time to 0.25s down from 0.5s because half a
second of sleeping for each chunk this happens on seems incredibly
overkill.

Making the nbt code raise a CorruptChunkError in this case also means
that failing to read a chunk due to an IOError is not a fatal error
anymore, it'll simply skip it and move on.
This commit is contained in:
Nicolas F
2020-06-25 15:30:54 +02:00
parent c53268e8fe
commit 1355f8c49e
2 changed files with 8 additions and 6 deletions

View File

@@ -292,7 +292,10 @@ class MCRFileReader(object):
self._file.seek(offset)
# read in the chunk data header
header = self._file.read(5)
try:
header = self._file.read(5)
except OSError as e:
raise CorruptChunkError("An OSError occurred: {}".format(e.strerror))
if len(header) != 5:
raise CorruptChunkError("chunk header is invalid")
data_length, compression = self._chunk_header_format.unpack(header)