mirror of
https://github.com/PaperMC/Paper.git
synced 2024-09-06 03:48:05 +02:00
Upstream has released updates that appears to apply and compile correctly. This update has been tested to ensure that World Conversion still occurs correctly. Bukkit Changes: 0812ce2c SPIGOT-4397: isChunkGenerated API CraftBukkit Changes:4824655c
SPIGOT-4398: Upgrade to ASM 6.2.1 for better Java 11 supporteea43870
MC-134115: Fix issues converting tile entities1a7f2d10
SPIGOT-4397: isChunkGenerated API40aed54d
SPIGOT-4396: Improve vehicle movement Spigot Changes: f6a273b1 Rebuild patches
42 lines
1.8 KiB
Diff
42 lines
1.8 KiB
Diff
From a78afbc2ce603e2addfd54b8614758bf400077fe Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Sat, 11 Aug 2018 00:49:20 -0400
|
|
Subject: [PATCH] Detect and repair corrupt Region Files
|
|
|
|
If the file has partial data written but not the full 8192 bytes,
|
|
then the server will be unable to load that region file...
|
|
|
|
I don't know why mojang only checks for 4096, when anything less than 8192 is a crash.
|
|
|
|
But to be safe, it will attempt to back up the file.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/RegionFile.java b/src/main/java/net/minecraft/server/RegionFile.java
|
|
index 5d2853b9ce..c35974aa7c 100644
|
|
--- a/src/main/java/net/minecraft/server/RegionFile.java
|
|
+++ b/src/main/java/net/minecraft/server/RegionFile.java
|
|
@@ -40,7 +40,20 @@ public class RegionFile {
|
|
}
|
|
|
|
this.c = new RandomAccessFile(file1, "rw");
|
|
- if (this.c.length() < 4096L) {
|
|
+ // Paper start - detect and fix incomplete headers
|
|
+ long length = this.c.length();
|
|
+ if (length < 8192 && length > 0) {
|
|
+ File corrupt = new File(file1.getParentFile(), file1.getName() + ".bak");
|
|
+ org.apache.logging.log4j.Logger logger = org.apache.logging.log4j.LogManager.getLogger();
|
|
+ logger.error("Region file " + file1 + " was incomplete. Backing up to " + corrupt + " and repairing");
|
|
+ try {
|
|
+ java.nio.file.Files.copy(file1.toPath(), corrupt.toPath());
|
|
+ } catch (IOException e) {
|
|
+ logger.error("Error backing up corrupt file", e);
|
|
+ }
|
|
+ }
|
|
+ if (length < 8192L) {
|
|
+ // Paper end
|
|
this.c.write(a);
|
|
this.c.write(a);
|
|
this.g += 8192;
|
|
--
|
|
2.19.0
|
|
|