Better error handling of errors when a world fails to open.
A common case is a corrupt (or empty) level.dat file. This condition wasn't properly caught, yielding a less-than-useful stack trace. Even more concerning is that this could happen when a user is just running "overviewer.py" to get a world listing. This has been fixed to improve the user experience
This commit is contained in:
@@ -792,9 +792,16 @@ def get_worlds():
|
||||
for dir in os.listdir("."):
|
||||
world_dat = os.path.join(dir, "level.dat")
|
||||
if not os.path.exists(world_dat): continue
|
||||
info = nbt.load(world_dat)[1]
|
||||
info['Data']['path'] = os.path.join(".", dir).decode(loc)
|
||||
if 'LevelName' in info['Data'].keys():
|
||||
ret[info['Data']['LevelName']] = info['Data']
|
||||
world_path = os.path.join(".", dir)
|
||||
try:
|
||||
info = nbt.load(world_dat)[1]
|
||||
info['Data']['path'] = world_path.decode(loc)
|
||||
if 'LevelName' in info['Data'].keys():
|
||||
ret[info['Data']['LevelName']] = info['Data']
|
||||
except nbt.CorruptNBTError:
|
||||
ret[os.path.basename(world_path).decode(loc) + " (corrupt)"] = {'path': world_path.decode(loc),
|
||||
'LastPlayed': 0,
|
||||
'Time': 0,
|
||||
'IsCorrupt': True}
|
||||
|
||||
return ret
|
||||
|
||||
Reference in New Issue
Block a user