Merge pull request #260 from MrBretze/master

Close the option
This commit is contained in:
TheMode 2021-05-04 04:25:13 +02:00 committed by GitHub
commit 22eb5c6bcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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