diff options
author | Spottedleaf <[email protected]> | 2021-12-19 09:40:39 -0800 |
---|---|---|
committer | Spottedleaf <[email protected]> | 2021-12-19 09:40:39 -0800 |
commit | 1bc077b7f4b49264c1975321fa25d743969b3b3b (patch) | |
tree | 2ee6f0618e6394ea0b731673ef614c3023976b19 | |
parent | 5bd2611b3a4bbbd2cbcb7cca185573052e791d11 (diff) | |
download | Paper-1bc077b7f4b49264c1975321fa25d743969b3b3b.tar.gz Paper-1bc077b7f4b49264c1975321fa25d743969b3b3b.zip |
Only write chunk data to disk if it serializes without throwing
This ensures at least a valid version of the chunk exists
on disk, even if outdated
-rw-r--r-- | patches/server/0847-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/patches/server/0847-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch b/patches/server/0847-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch new file mode 100644 index 0000000000..d90860ed6f --- /dev/null +++ b/patches/server/0847-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch @@ -0,0 +1,37 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Spottedleaf <[email protected]> +Date: Sun, 19 Dec 2021 09:40:10 -0800 +Subject: [PATCH] Only write chunk data to disk if it serializes without + throwing + +This ensures at least a valid version of the chunk exists +on disk, even if outdated + +diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +index e360ff62d3be252d6b9746b00dbdb4a2aae95405..1d713251957fe874592c170aa017a16bd34712a4 100644 +--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java ++++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +@@ -272,10 +272,11 @@ public class RegionFileStorage implements AutoCloseable { + NbtIo.write(nbt, (DataOutput) dataoutputstream); + regionfile.setStatus(pos.x, pos.z, ChunkSerializer.getStatus(nbt)); // Paper - cache status on disk + regionfile.setOversized(pos.x, pos.z, false); // Paper - We don't do this anymore, mojang stores differently, but clear old meta flag if it exists to get rid of our own meta file once last oversized is gone ++ dataoutputstream.close(); // Paper - only write if successful + } catch (Throwable throwable) { + if (dataoutputstream != null) { + try { +- dataoutputstream.close(); ++ //dataoutputstream.close(); // Paper - don't write garbage data to disk if writing serialization fails + } catch (Throwable throwable1) { + throwable.addSuppressed(throwable1); + } +@@ -284,9 +285,7 @@ public class RegionFileStorage implements AutoCloseable { + throw throwable; + } + +- if (dataoutputstream != null) { +- dataoutputstream.close(); +- } ++ // Paper - move into try block to only write if successfully serialized + } + + // Paper start |