Fix self-healing for corrupted render-state files, fixes: #588

This commit is contained in:
Lukas Rieger (Blue) 2024-09-15 10:09:53 +02:00
parent f25ebfead3
commit 48fa5b6abc
No known key found for this signature in database
GPG Key ID: AA33883B1BBA03E6

View File

@ -92,7 +92,17 @@ private synchronized T loadCell(Vector2i pos) {
return BLUE_NBT.read(in.decompress(), type);
} catch (IOException ex) {
Logger.global.logError("Failed to load render-state cell " + pos, ex);
} catch (RuntimeException ex) { // E.g. NoSuchElementException thrown by BlueNBT if there is a format error
Logger.global.logError("Failed to load render-state cell " + pos, ex);
// try to delete the possibly corrupted file for self-healing
try {
storage.delete(pos.getX(), pos.getY());
} catch (IOException e) {
Logger.global.logError("Failed to delete render-state cell " + pos, e);
}
}
return createNewCell();
}