minor fixes
This commit is contained in:
1 parent
455b8c0d4a
commit
82ae81c7af
2 files changed
+10
-4
No files matched your search
@@ -24,6 +24,7 @@ public class BundleWriter implements Closeable {
|
|||||||
protected final ByteBufAllocator allocator;
|
protected final ByteBufAllocator allocator;
|
||||||
protected final boolean allowReassemble;
|
protected final boolean allowReassemble;
|
||||||
protected final int compressionLevel;
|
protected final int compressionLevel;
|
||||||
|
protected final boolean verbose;
|
||||||
protected final Path relativeRoot;
|
protected final Path relativeRoot;
|
||||||
protected final EntryOutputStream outputStream;
|
protected final EntryOutputStream outputStream;
|
||||||
|
|
||||||
@@ -35,12 +36,13 @@ public class BundleWriter implements Closeable {
|
|||||||
int maxWorkers,
|
int maxWorkers,
|
||||||
Path relativeRoot,
|
Path relativeRoot,
|
||||||
OutputStream outputStream,
|
OutputStream outputStream,
|
||||||
byte[] dictionary, ByteBufAllocator allocator
|
byte[] dictionary, ByteBufAllocator allocator, boolean verbose
|
||||||
) {
|
) {
|
||||||
this.allowReassemble = allowGunzip;
|
this.allowReassemble = allowGunzip;
|
||||||
this.compressionLevel = compressionLevel;
|
this.compressionLevel = compressionLevel;
|
||||||
this.relativeRoot = relativeRoot;
|
this.relativeRoot = relativeRoot;
|
||||||
this.allocator = allocator == null ? ByteBufAllocator.DEFAULT : allocator;
|
this.allocator = allocator == null ? ByteBufAllocator.DEFAULT : allocator;
|
||||||
|
this.verbose = verbose;
|
||||||
var zstdOut = new ZstdOutputStreamNoFinalizer(outputStream, compressionLevel);
|
var zstdOut = new ZstdOutputStreamNoFinalizer(outputStream, compressionLevel);
|
||||||
if (dictionary != null) {
|
if (dictionary != null) {
|
||||||
zstdOut.setDict(new ZstdDictCompress(dictionary, compressionLevel));
|
zstdOut.setDict(new ZstdDictCompress(dictionary, compressionLevel));
|
||||||
@@ -151,11 +153,11 @@ public class BundleWriter implements Closeable {
|
|||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
private void writeReassembleInMem(Path path) {
|
private void writeReassembleInMem(Path path) {
|
||||||
if (!"region".equals(path.getParent().toString()) && !path.toString().endsWith(".mca")) {
|
if (!"region".equals(path.getParent().toString()) && !path.toString().endsWith(".mca")) {
|
||||||
System.out.println("Mismatch " + path + ", parent: " + path.getParent());
|
if(verbose) System.out.println("Mismatch " + path + ", parent: " + path.getParent());
|
||||||
writePlain(path);
|
writePlain(path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
System.out.println("Reassembling " + path);
|
if(verbose) System.out.println("Reassembling " + path);
|
||||||
var uncompressed = allocator.buffer();
|
var uncompressed = allocator.buffer();
|
||||||
var rPath = relativeRoot.toAbsolutePath().relativize(path.toAbsolutePath());
|
var rPath = relativeRoot.toAbsolutePath().relativize(path.toAbsolutePath());
|
||||||
try (var out = new EntryOutputStream(new ByteBufOutputStream(uncompressed));
|
try (var out = new EntryOutputStream(new ByteBufOutputStream(uncompressed));
|
||||||
|
|||||||
@@ -24,8 +24,12 @@ public class RegionParser implements Closeable {
|
|||||||
if (size < 8192) throw new IOException("The region file " + file + " has been truncated");
|
if (size < 8192) throw new IOException("The region file " + file + " has been truncated");
|
||||||
if(size > 8388608 * 2) throw new IOException("The region file " + file + " is too large"); //todo bug
|
if(size > 8388608 * 2) throw new IOException("The region file " + file + " is too large"); //todo bug
|
||||||
source = allocator.buffer(size);
|
source = allocator.buffer(size);
|
||||||
|
|
||||||
try (var fc = FileChannel.open(file, StandardOpenOption.READ)) {
|
try (var fc = FileChannel.open(file, StandardOpenOption.READ)) {
|
||||||
while (source.writeBytes(fc, 0L, (int) size) > 0) ;
|
var toRead = size;
|
||||||
|
while(toRead > 0){
|
||||||
|
toRead -= source.writeBytes(fc, 0L, (int) size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user