mcaselector icon indicating copy to clipboard operation
mcaselector copied to clipboard

Chunk deletion fails silently on region files without proper sector padding

Open terbin opened this issue 1 year ago • 0 comments

Describe the bug Chunk deletion fails silently on region files that don't have proper 4096-byte sector padding on the last chunk. The operation appears to complete successfully but the files are unchanged. This affects files exported by tools like WorldTools.

To Reproduce

  1. Download a world using WorldTools (creates region files without full sector padding)
  2. Open the downloaded world in MCA Selector
  3. Select some chunks
  4. Use Selection > Delete selected chunks
  5. Operation appears to complete successfully
  6. Check the world - chunks are NOT deleted

Expected behavior Selected chunks should be deleted from the region files.

Screenshots and other files From debug.log:

r.-559.-600.zip

11:56:34.680 [savePool-thread-1] WARN SelectionDeleter: failed to delete selected chunks from r.-559.-600.mca
java.io.EOFException: null
	at java.base/java.io.RandomAccessFile.readFully(Unknown Source) ~[?:?]
	at java.base/java.io.RandomAccessFile.readFully(Unknown Source) ~[?:?]
	at net.querz.mcaselector.io.mca.MCAFile.deFragment(MCAFile.java:204) ~[mcaselector.jar:?]
	...

Environment (please complete the following information):

  • OS: Windows 11 (used Windows installer)
  • Version of MCA Selector: 2.6.1 (also affects 2.6.0)

Additional context

  • Works correctly in version 2.5.3
  • Introduced in commit b0944681 which changed DataInputStream.read(data) to RandomAccessFile.readFully(data) in the deFragment() method
  • read() handles partial reads gracefully (returns bytes read)
  • readFully() throws EOFException if file ends early
  • WorldTools exports region files where the last chunk isn't padded to full sector boundaries, triggering the EOFException
  • The exception is caught and logged, but progress continues - so the user sees success while the file is unchanged

terbin avatar Dec 04 '25 11:12 terbin