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:
os.unlink(chunkfile) # Remove the file so that the next run will re-generate it.
# Do some string manipulation to determine what the chunk file is os.unlink(chunkfile)
# that goes with this image. Then call chunk.render_and_save except OSError, e:
dirname, imagename = os.path.split(chunkfile) import errno
parts = imagename.split(".") # Ignore if file doesn't exist, another task could have already
datafile = "c.{0}.{1}.dat".format(parts[1],parts[2]) # removed it.
#print "Chunk came from data file", datafile if e.errno != errno.ENOENT:
# XXX Don't forget to set cave mode here when it gets implemented! print "Could not remove the corrupt chunk!"
chunk.render_and_save(os.path.join(dirname, datafile), False) raise
chunkimg = Image.open(chunkfile) else:
print "Success" print "Removed the corrupt file"
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