Possible fix a when storage location is closed an re opened

This commit is contained in:
MrBretzel 2021-04-21 23:53:47 +02:00 committed by ALS
parent fdcaefaf86
commit 8047a203cb

View File

@ -19,6 +19,8 @@ import java.nio.file.Paths;
*/
public class FileStorageSystem implements StorageSystem {
private Options options;
static {
RocksDB.loadLibrary();
}
@ -32,11 +34,11 @@ public class FileStorageSystem implements StorageSystem {
@Override
public void open(@NotNull String location, @NotNull StorageOptions storageOptions) {
Options options = new Options().setCreateIfMissing(true);
options = new Options().setCreateIfMissing(true);
if (storageOptions.hasCompression()) {
options.setCompressionType(CompressionType.ZSTD_COMPRESSION);
options.setCompressionOptions(new CompressionOptions().setLevel(1));
options.setCompressionOptions(new CompressionOptions().setLevel(4));
}
try {
@ -78,6 +80,10 @@ public class FileStorageSystem implements StorageSystem {
public void close() {
try {
this.rocksDB.closeE();
if (options != null)
this.options.close();
} catch (RocksDBException e) {
MinecraftServer.getExceptionManager().handleException(e);
}