mirror of
https://github.com/boy0001/FastAsyncWorldedit.git
synced 2024-12-01 07:03:52 +01:00
Fix error from flushing on different thread
This commit is contained in:
parent
d4fd374caa
commit
d61c21f60e
@ -134,33 +134,35 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
|
||||
@Override
|
||||
public boolean flush() {
|
||||
super.flush();
|
||||
boolean flushed = osBD != null || osNBTF != null || osNBTT != null && osENTCF != null || osENTCT != null;
|
||||
try {
|
||||
if (osBD != null) {
|
||||
osBD.close();
|
||||
osBD = null;
|
||||
synchronized (this) {
|
||||
super.flush();
|
||||
boolean flushed = osBD != null || osNBTF != null || osNBTT != null && osENTCF != null || osENTCT != null;
|
||||
try {
|
||||
if (osBD != null) {
|
||||
osBD.close();
|
||||
osBD = null;
|
||||
}
|
||||
if (osNBTF != null) {
|
||||
osNBTF.close();
|
||||
osNBTF = null;
|
||||
}
|
||||
if (osNBTT != null) {
|
||||
osNBTT.close();
|
||||
osNBTT = null;
|
||||
}
|
||||
if (osENTCF != null) {
|
||||
osENTCF.close();
|
||||
osENTCF = null;
|
||||
}
|
||||
if (osENTCT != null) {
|
||||
osENTCT.close();
|
||||
osENTCT = null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MainUtil.handleError(e);
|
||||
}
|
||||
if (osNBTF != null) {
|
||||
osNBTF.close();
|
||||
osNBTF = null;
|
||||
}
|
||||
if (osNBTT != null) {
|
||||
osNBTT.close();
|
||||
osNBTT = null;
|
||||
}
|
||||
if (osENTCF != null) {
|
||||
osENTCF.close();
|
||||
osENTCF = null;
|
||||
}
|
||||
if (osENTCT != null) {
|
||||
osENTCT.close();
|
||||
osENTCT = null;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MainUtil.handleError(e);
|
||||
return flushed;
|
||||
}
|
||||
return flushed;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -199,11 +201,13 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
|
||||
if (osBD != null) {
|
||||
return osBD;
|
||||
}
|
||||
bdFile.getParentFile().mkdirs();
|
||||
bdFile.createNewFile();
|
||||
osBD = getCompressedOS(new FileOutputStream(bdFile));
|
||||
writeHeader(osBD, x, y, z);
|
||||
return osBD;
|
||||
synchronized (this) {
|
||||
bdFile.getParentFile().mkdirs();
|
||||
bdFile.createNewFile();
|
||||
osBD = getCompressedOS(new FileOutputStream(bdFile));
|
||||
writeHeader(osBD, x, y, z);
|
||||
return osBD;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,42 +48,44 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet {
|
||||
|
||||
@Override
|
||||
public boolean flush() {
|
||||
super.flush();
|
||||
try {
|
||||
if (idsStream != null) {
|
||||
idsStreamZip.close();
|
||||
size = idsStream.getSize();
|
||||
ids = idsStream.toByteArrays();
|
||||
idsStream = null;
|
||||
idsStreamZip = null;
|
||||
synchronized (this) {
|
||||
super.flush();
|
||||
try {
|
||||
if (idsStream != null) {
|
||||
idsStreamZip.close();
|
||||
size = idsStream.getSize();
|
||||
ids = idsStream.toByteArrays();
|
||||
idsStream = null;
|
||||
idsStreamZip = null;
|
||||
}
|
||||
if (entCStream != null) {
|
||||
entCStreamZip.close();
|
||||
entC = entCStream.toByteArrays();
|
||||
entCStream = null;
|
||||
entCStreamZip = null;
|
||||
}
|
||||
if (entRStream != null) {
|
||||
entRStreamZip.close();
|
||||
entR = entRStream.toByteArrays();
|
||||
entRStream = null;
|
||||
entRStreamZip = null;
|
||||
}
|
||||
if (tileCStream != null) {
|
||||
tileCStreamZip.close();
|
||||
tileC = tileCStream.toByteArrays();
|
||||
tileCStream = null;
|
||||
tileCStreamZip = null;
|
||||
}
|
||||
if (tileRStream != null) {
|
||||
tileRStreamZip.close();
|
||||
tileR = tileRStream.toByteArrays();
|
||||
tileRStream = null;
|
||||
tileRStreamZip = null;
|
||||
}
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
MainUtil.handleError(e);
|
||||
}
|
||||
if (entCStream != null) {
|
||||
entCStreamZip.close();
|
||||
entC = entCStream.toByteArrays();
|
||||
entCStream = null;
|
||||
entCStreamZip = null;
|
||||
}
|
||||
if (entRStream != null) {
|
||||
entRStreamZip.close();
|
||||
entR = entRStream.toByteArrays();
|
||||
entRStream = null;
|
||||
entRStreamZip = null;
|
||||
}
|
||||
if (tileCStream != null) {
|
||||
tileCStreamZip.close();
|
||||
tileC = tileCStream.toByteArrays();
|
||||
tileCStream = null;
|
||||
tileCStreamZip = null;
|
||||
}
|
||||
if (tileRStream != null) {
|
||||
tileRStreamZip.close();
|
||||
tileR = tileRStream.toByteArrays();
|
||||
tileRStream = null;
|
||||
tileRStreamZip = null;
|
||||
}
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
MainUtil.handleError(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -110,11 +112,13 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet {
|
||||
if (idsStreamZip != null) {
|
||||
return idsStreamZip;
|
||||
}
|
||||
setOrigin(x, z);
|
||||
idsStream = new FastByteArrayOutputStream(Settings.HISTORY.BUFFER_SIZE);
|
||||
idsStreamZip = getCompressedOS(idsStream);
|
||||
writeHeader(idsStreamZip, x, y, z);
|
||||
return idsStreamZip;
|
||||
synchronized (this) {
|
||||
setOrigin(x, z);
|
||||
idsStream = new FastByteArrayOutputStream(Settings.HISTORY.BUFFER_SIZE);
|
||||
idsStreamZip = getCompressedOS(idsStream);
|
||||
writeHeader(idsStreamZip, x, y, z);
|
||||
return idsStreamZip;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user