From 8578facfe7d943a81c37e7e8e74c207236f62aa7 Mon Sep 17 00:00:00 2001 From: Andrea Cavalli Date: Thu, 9 Jun 2022 16:47:42 +0200 Subject: [PATCH] Check persistent cache directory --- .../database/disk/LLLocalKeyValueDatabase.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/main/java/it/cavallium/dbengine/database/disk/LLLocalKeyValueDatabase.java b/src/main/java/it/cavallium/dbengine/database/disk/LLLocalKeyValueDatabase.java index 8b55806..192153d 100644 --- a/src/main/java/it/cavallium/dbengine/database/disk/LLLocalKeyValueDatabase.java +++ b/src/main/java/it/cavallium/dbengine/database/disk/LLLocalKeyValueDatabase.java @@ -861,6 +861,20 @@ public class LLLocalKeyValueDatabase implements LLKeyValueDatabase { } else { databasesDirPath = null; } + //noinspection ConstantConditions + if (databaseOptions.persistentCaches() != null) { + for (var persistentCache : databaseOptions.persistentCaches()) { + var persistentCachePath = Paths.get(persistentCache.path()); + if (Files.notExists(persistentCachePath)) { + Files.createDirectories(persistentCachePath); + if (!Files.isDirectory(persistentCachePath)) { + throw new IllegalArgumentException( + "Persistent cache \"" + persistentCache.id() + "\" path \"" + persistentCachePath + + "\" is not a directory!"); + } + } + } + } // the Options class contains a set of configurable DB options // that determines the behaviour of the database.