Skip to content

Commit 08e3069

Browse files
committed
Make sure cache journal file exists
1 parent 2e8db57 commit 08e3069

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

core/src/main/java/xyz/gianlu/librespot/cache/CacheJournal.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
import org.jetbrains.annotations.Nullable;
55
import xyz.gianlu.librespot.common.Utils;
66

7-
import java.io.*;
7+
import java.io.Closeable;
8+
import java.io.File;
9+
import java.io.IOException;
10+
import java.io.RandomAccessFile;
811
import java.nio.charset.StandardCharsets;
912
import java.util.*;
1013

@@ -29,8 +32,11 @@ class CacheJournal implements Closeable {
2932
private final RandomAccessFile io;
3033
private final Map<String, Entry> entries = Collections.synchronizedMap(new HashMap<>(1024));
3134

32-
CacheJournal(@NotNull File parent) throws FileNotFoundException {
35+
CacheJournal(@NotNull File parent) throws IOException {
3336
File file = new File(parent, "journal.dat");
37+
if (!file.exists() && !file.createNewFile())
38+
throw new IOException("Failed creating empty cache journal.");
39+
3440
io = new RandomAccessFile(file, "rwd");
3541
}
3642

0 commit comments

Comments
 (0)