Skip to content

Commit 18252a4

Browse files
author
Lukas Molzberger
committed
create model dirs if necessary
1 parent 4bf113e commit 18252a4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import network.aika.SuspensionHook;
2121

2222
import java.io.*;
23+
import java.nio.file.Files;
24+
import java.nio.file.Path;
2325
import java.util.Collections;
2426
import java.util.HashMap;
2527
import java.util.Map;
@@ -40,16 +42,17 @@ public class FSSuspensionCallbackImpl implements SuspensionHook {
4042
private Map<String, Integer> labels = Collections.synchronizedMap(new HashMap<>());
4143
private Map<Integer, long[]> index = Collections.synchronizedMap(new TreeMap<>());
4244

43-
private File path;
45+
private Path path;
4446
private String modelLabel;
4547

4648
private RandomAccessFile dataStore;
4749

4850

49-
public void open(File path, String modelLabel, boolean create) throws FileNotFoundException {
51+
public void open(Path path, String modelLabel, boolean create) throws IOException {
5052
this.path = path;
5153
this.modelLabel = modelLabel;
5254
if(create) {
55+
Files.createDirectories(path);
5356
File modelFile = getFile(MODEL);
5457
if(modelFile.exists())
5558
modelFile.delete();
@@ -148,7 +151,7 @@ public void storeIndex() {
148151
}
149152

150153
private File getFile(String prefix) {
151-
return new File(path, prefix + "-" + modelLabel + ".dat");
154+
return new File(path.toFile(), prefix + "-" + modelLabel + ".dat");
152155
}
153156

154157
private void readIndex(DataInput in) throws IOException {

0 commit comments

Comments
 (0)