Skip to content

Commit a5d7bcb

Browse files
committed
ahahagah
1 parent eda5c25 commit a5d7bcb

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

core/src/main/java/pl/skidam/automodpack_core/utils/SmartFileUtils.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ public static void createParentDirs(Path file) throws IOException {
106106
}
107107
}
108108

109+
public static void createParentDirsNoEx(Path file) {
110+
try {
111+
createParentDirs(file);
112+
} catch (IOException e) {
113+
LOGGER.error("Failed to create parent dirs", e);
114+
}
115+
}
116+
109117
public static boolean isEmptyDirectory(Path parentPath) throws IOException {
110118
if (!Files.isDirectory(parentPath)) return false;
111119
try (Stream<Path> pathStream = Files.list(parentPath)) {

core/src/main/java/pl/skidam/automodpack_core/utils/cache/FileMetadataCache.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import org.h2.mvstore.MVMap;
44
import org.h2.mvstore.MVStore;
55
import pl.skidam.automodpack_core.utils.HashUtils;
6+
import pl.skidam.automodpack_core.utils.SmartFileUtils;
67

78
import java.io.IOException;
89
import java.io.Serializable;
@@ -33,6 +34,7 @@ public record CachedFile(String contentHash, long lastModified, long size, Strin
3334

3435
public static FileMetadataCache open(Path path) {
3536
Path absPath = path.toAbsolutePath().normalize();
37+
SmartFileUtils.createParentDirsNoEx(absPath);
3638
synchronized (GLOBAL_LOCK) {
3739
FileMetadataCache existing = INSTANCES.get(absPath);
3840
if (existing != null) {

core/src/main/java/pl/skidam/automodpack_core/utils/cache/ModFileCache.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import org.h2.mvstore.MVMap;
44
import org.h2.mvstore.MVStore;
55
import pl.skidam.automodpack_core.utils.FileInspection;
6+
import pl.skidam.automodpack_core.utils.SmartFileUtils;
67

78
import java.io.IOException;
89
import java.nio.file.Files;
@@ -27,6 +28,7 @@ public class ModFileCache implements AutoCloseable {
2728

2829
public static ModFileCache open(Path path) {
2930
Path absPath = path.toAbsolutePath().normalize();
31+
SmartFileUtils.createParentDirsNoEx(absPath);
3032
synchronized (GLOBAL_LOCK) {
3133
ModFileCache existing = INSTANCES.get(absPath);
3234
if (existing != null) {

0 commit comments

Comments
 (0)