Skip to content

Commit ea5dbdc

Browse files
author
Lukas Molzberger
committed
fix
1 parent 305ee76 commit ea5dbdc

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<groupId>network.aika</groupId>
66
<artifactId>aika</artifactId>
77
<packaging>jar</packaging>
8-
<version>1.4.18</version>
8+
<version>1.4.19</version>
99
<name>aika</name>
1010
<url>https://aika.network</url>
1111
<description>An Artificial Intelligence for Knowledge Acquisition</description>
@@ -30,7 +30,7 @@
3030
<url>https://github.com/aika-algorithm/aika</url>
3131
<connection>scm:git:git://github.com/aika-algorithm/aika.git</connection>
3232
<developerConnection>scm:git:[email protected]:aika-algorithm/aika.git</developerConnection>
33-
<tag>aika-1.4.16</tag>
33+
<tag>aika-1.4.19</tag>
3434
</scm>
3535

3636

src/main/java/network/aika/storage/FSSuspensionCallbackImpl.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
*/
3232
public class FSSuspensionCallbackImpl implements SuspensionHook {
3333

34+
public static String MODEL = "model";
35+
public static String INDEX = "index";
36+
3437
private AtomicInteger currentId = new AtomicInteger(0);
3538

3639
private Map<String, Integer> labels = Collections.synchronizedMap(new TreeMap<>());
@@ -46,12 +49,18 @@ public void open(File path, String modelLabel, boolean create) throws FileNotFou
4649
this.path = path;
4750
this.modelLabel = modelLabel;
4851
if(create) {
49-
getFile("model").deleteOnExit();
50-
getFile("index").deleteOnExit();
52+
File modelFile = getFile(MODEL);
53+
if(modelFile.exists())
54+
modelFile.deleteOnExit();
55+
56+
File indexFile = getFile(INDEX);
57+
if(indexFile.exists())
58+
indexFile.deleteOnExit();
59+
5160
} else {
5261
loadIndex();
5362
}
54-
dataStore = new RandomAccessFile(getFile("model"), "rw");
63+
dataStore = new RandomAccessFile(getFile(MODEL), "rw");
5564
}
5665

5766
public void close() throws IOException {
@@ -115,7 +124,7 @@ public Iterable<Integer> getAllNodeIds() {
115124

116125
@Override
117126
public void loadIndex() {
118-
try (FileInputStream fis = new FileInputStream(getFile("index"));
127+
try (FileInputStream fis = new FileInputStream(getFile(INDEX));
119128
ByteArrayInputStream bais = new ByteArrayInputStream(fis.readAllBytes());
120129
DataInputStream dis = new DataInputStream(bais)) {
121130
readIndex(dis);
@@ -129,7 +138,7 @@ public void storeIndex() {
129138
ByteArrayOutputStream baos = new ByteArrayOutputStream();
130139

131140
try (DataOutputStream dos = new DataOutputStream(baos);
132-
FileOutputStream fos = new FileOutputStream(getFile("index"))) {
141+
FileOutputStream fos = new FileOutputStream(getFile(INDEX))) {
133142
writeIndex(dos);
134143
fos.write(baos.toByteArray());
135144
} catch (IOException e) {

0 commit comments

Comments
 (0)