0

fixed corrupt chunk handling code.

Instead of re-gening the chunk, it now removes it and leaves it alone.
The reason is that, now that the cache dir is separated from the chunk
data files, there's no way for that code to know where it came from. For
now, it's easier to just omit that one chunk, it'll be re-generated on
the next run anyways.
This commit is contained in:
Andrew Brown
2010-09-25 23:10:49 -04:00
parent 8d2c575758
commit f5f572a92b

View File

@@ -534,19 +534,27 @@ def render_worldtile(chunks, colstart, colend, rowstart, rowend, path):
chunkimg = Image.open(chunkfile) chunkimg = Image.open(chunkfile)
chunkimg.load() chunkimg.load()
except IOError, e: except IOError, e:
# If for some reason the chunk failed to load (perhaps a previous
# run was canceled and the file was only written half way,
# corrupting it), then this could error.
# Since we have no easy way of determining how this chunk was
# generated, we need to just ignore it.
print "Error opening file", chunkfile print "Error opening file", chunkfile
print "Attempting to re-generate it..." try:
# Remove the file so that the next run will re-generate it.
os.unlink(chunkfile) os.unlink(chunkfile)
# Do some string manipulation to determine what the chunk file is except OSError, e:
# that goes with this image. Then call chunk.render_and_save import errno
dirname, imagename = os.path.split(chunkfile) # Ignore if file doesn't exist, another task could have already
parts = imagename.split(".") # removed it.
datafile = "c.{0}.{1}.dat".format(parts[1],parts[2]) if e.errno != errno.ENOENT:
#print "Chunk came from data file", datafile print "Could not remove the corrupt chunk!"
# XXX Don't forget to set cave mode here when it gets implemented! raise
chunk.render_and_save(os.path.join(dirname, datafile), False) else:
chunkimg = Image.open(chunkfile) print "Removed the corrupt file"
print "Success"
print "You will need to re-run the Overviewer to fix this chunk"
continue
xpos = -192 + (col-colstart)*192 xpos = -192 + (col-colstart)*192
ypos = -96 + (row-rowstart)*96 ypos = -96 + (row-rowstart)*96