From dd6197922c199da9d1054b14b26c69015fbdb324 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Wed, 10 May 2023 17:27:44 +0100 Subject: [PATCH] fix: remove invalid file length check - NBT is stored at the end of the clipboard file - Fixes #2209 --- .../clipboard/DiskOptimizedClipboard.java | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/DiskOptimizedClipboard.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/DiskOptimizedClipboard.java index 100e3265f..b54c075fc 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/DiskOptimizedClipboard.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/DiskOptimizedClipboard.java @@ -173,7 +173,6 @@ public class DiskOptimizedClipboard extends LinearClipboard { nbtMap = new HashMap<>(); try { this.file = file; - checkFileLength(file); this.braf = new RandomAccessFile(file, "rw"); braf.setLength(file.length()); this.nbtBytesRemaining = Integer.MAX_VALUE - (int) file.length(); @@ -202,32 +201,6 @@ public class DiskOptimizedClipboard extends LinearClipboard { } } - private void checkFileLength(File file) throws IOException { - long expectedFileSize = headerSize + ((long) getVolume() << 1); - if (file.length() > Integer.MAX_VALUE) { - if (expectedFileSize >= Integer.MAX_VALUE) { - throw new IOException(String.format( - "Cannot load clipboard of file size: %d > 2147483647 bytes (2.147 GiB), " + "volume: %d blocks", - file.length(), - getVolume() - )); - } else { - throw new IOException(String.format( - "Cannot load clipboard of file size > 2147483647 bytes (2.147 GiB). Possible corrupt file? Mismatch" + - " between volume `%d` and file length `%d`!", - file.length(), - getVolume() - )); - } - } else if (expectedFileSize != file.length()) { - throw new IOException(String.format( - "Possible corrupt clipboard file? Mismatch between expected file size `%d` and actual file size `%d`!", - expectedFileSize, - file.length() - )); - } - } - /** * Attempt to load a file into a new {@link DiskOptimizedClipboard} instance. Will attempt to recover on version mismatch * failure.