From 48fa5b6abcdb1452eac5c23bcb25a7679cc01508 Mon Sep 17 00:00:00 2001 From: "Lukas Rieger (Blue)" Date: Sun, 15 Sep 2024 10:09:53 +0200 Subject: [PATCH] Fix self-healing for corrupted render-state files, fixes: #588 --- .../bluemap/core/map/renderstate/CellStorage.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/src/main/java/de/bluecolored/bluemap/core/map/renderstate/CellStorage.java b/core/src/main/java/de/bluecolored/bluemap/core/map/renderstate/CellStorage.java index 713a696e..a4336d94 100644 --- a/core/src/main/java/de/bluecolored/bluemap/core/map/renderstate/CellStorage.java +++ b/core/src/main/java/de/bluecolored/bluemap/core/map/renderstate/CellStorage.java @@ -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(); }