feat: implement backup system with compression and bundling

- Add zstd-jni dependency for compression support
- Define Backup record with name, key, incremental, and size fields
- Implement BackupManager with backup listing, deletion, and creation methods
- Create BackupWorker to handle backup operations with server state coordination
- Refactor WorldDir to simplify dimension handling and file listing
- Introduce bundling system with SerialBundlerReader^[[1;5P/Writer for efficient storage
- Add BackupStrategy interface with LocalBackupStrategy implementation
- Support both compressed and uncompressed backup formats
- Add config option for parallel backup operations
- Remove old backup implementation from JustBackupMod
- Update backup file format with metadata footer and magic number validation
This commit is contained in:
iceBear67 committed 2025-09-21 22:03:46 +08:00
1 parent bc9fab8d22
commit 6a2642ab93
14 files changed
+460 -72

No files matched your search

@@ -0,0 +1,37 @@
package io.ib67.sfcraft.bundler;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
public class EntryOutputStream extends FilterOutputStream {
/**
* Creates an output stream filter built on top of the specified
* underlying output stream.
*
* @param out the underlying output stream to be assigned to
* the field {@code this.out} for later use, or
* {@code null} if this instance is to be
* created without an underlying stream.
*/
public EntryOutputStream(OutputStream out) {
super(out);
}
public void writeMagic() throws IOException {
out.write(BundlerEntry.MAGIC);
}
public void write(BundlerEntry entry) throws IOException {
var fileName = entry.fileName().getBytes(StandardCharsets.UTF_8);
var buf = ByteBuffer.allocate(4).putInt(entry.unGzipped() ? fileName.length * -1 : fileName.length);
out.write(buf.array());
out.write(fileName);
buf = ByteBuffer.allocate(8 + 8);
buf.putLong(entry.fileLength());
buf.putLong(entry.offset());
out.write(buf.array());
}
}