Skip to content

Commit 48fa5b6

Browse files
committed
Fix self-healing for corrupted render-state files, fixes: #588
1 parent f25ebfe commit 48fa5b6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

core/src/main/java/de/bluecolored/bluemap/core/map/renderstate/CellStorage.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,17 @@ private synchronized T loadCell(Vector2i pos) {
9292
return BLUE_NBT.read(in.decompress(), type);
9393
} catch (IOException ex) {
9494
Logger.global.logError("Failed to load render-state cell " + pos, ex);
95+
} catch (RuntimeException ex) { // E.g. NoSuchElementException thrown by BlueNBT if there is a format error
96+
Logger.global.logError("Failed to load render-state cell " + pos, ex);
97+
98+
// try to delete the possibly corrupted file for self-healing
99+
try {
100+
storage.delete(pos.getX(), pos.getY());
101+
} catch (IOException e) {
102+
Logger.global.logError("Failed to delete render-state cell " + pos, e);
103+
}
95104
}
105+
96106
return createNewCell();
97107
}
98108

0 commit comments

Comments
 (0)