Skip to content

Commit e28461f

Browse files
thscthsc
authored andcommitted
chunkreader can be openend with empty root folder - asp3engine not!
1 parent 2cffdc3 commit e28461f

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/net/sharksystem/asp3/ASP3EngineFS.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,32 @@ private ASP3EngineFS(String rootDirectory,
2424
public static ASP3ChunkStorage getASP3ChunkStorage(String owner, String rootDirectory)
2525
throws IOException, ASP3Exception {
2626

27+
// check if root directory already exists. If not srt it up
28+
File root = new File(rootDirectory);
29+
if(!root.exists()) {
30+
root.mkdirs();
31+
}
32+
2733
return ASP3EngineFS.getASP3Engine(owner, rootDirectory, null);
2834

2935
}
3036

3137
public static ASP3ChunkStorage getASP3ChunkStorage(String rootDirectory)
3238
throws IOException, ASP3Exception {
3339

34-
return ASP3EngineFS.getASP3Engine(ASP3EngineFS.DEFAULT_OWNER, rootDirectory, null);
40+
return ASP3EngineFS.getASP3ChunkStorage(ASP3EngineFS.DEFAULT_OWNER, rootDirectory);
3541

3642
}
3743

3844
public static ASP3Engine getASP3Engine(String owner, String rootDirectory,
3945
ASP3Reader reader) throws IOException, ASP3Exception {
4046

47+
// root directory must exist when setting up an engine
48+
File root = new File(rootDirectory);
49+
if(!root.exists() || !root.isDirectory()) {
50+
throw new ASP3Exception("chunk root directory must exist when creating an ASP3Engine");
51+
}
52+
4153
ASP3EngineFS engine = new ASP3EngineFS(
4254
rootDirectory,
4355
new ASP3StorageFS(rootDirectory),

0 commit comments

Comments
 (0)