Add verification pass to updateDefaultPaths method
Some checks failed
PRs & Pushes / build (push) Failing after 1m39s
PRs & Pushes / build-apidoc (push) Failing after 1m49s

This commit is contained in:
JeremyStar™ 2024-12-15 13:50:53 +01:00
parent 1fc337d9b8
commit 2cfc8cad9d
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D

View file

@ -139,34 +139,43 @@ class FileAccess {
* Updates all default paths to * Updates all default paths to
* their platform-specific path. * their platform-specific path.
* *
* @throws VerificationFailedException if path creation fails
* @since v1-alpha10 * @since v1-alpha10
*/ */
@Throws(VerificationFailedException::class)
internal fun updateDefaultPaths() { internal fun updateDefaultPaths() {
logger.diag("Updating default paths") logger.diag("Updating default paths")
// Storage // Storage
homeDirectory = FileAccess(System.getProperty("user.home")).createDirectory() homeDirectory = FileAccess(System.getProperty("user.home"))
.createDirectory().verifyIsDirectory()
configDirectory = FileAccess(when (Environment.operatingSystem) { configDirectory = FileAccess(when (Environment.operatingSystem) {
LINUX, FREEBSD, NETBSD, OPENBSD -> "${homeDirectory}/.config" LINUX, FREEBSD, NETBSD, OPENBSD -> "${homeDirectory}/.config"
WINDOWS -> "${homeDirectory}/AppData/Roaming/sosengine-config" WINDOWS -> "${homeDirectory}/AppData/Roaming/sosengine-config"
else -> "${homeDirectory}/.sosengine/config" else -> "${homeDirectory}/.sosengine/config"
}).createDirectory() }).createDirectory().verifyIsDirectory()
dataDirectory = FileAccess(when (Environment.operatingSystem) { dataDirectory = FileAccess(when (Environment.operatingSystem) {
LINUX, FREEBSD, NETBSD, OPENBSD -> "${homeDirectory}/.local/share" LINUX, FREEBSD, NETBSD, OPENBSD -> "${homeDirectory}/.local/share"
WINDOWS -> "${homeDirectory}/AppData/Roaming/sosengine-data" WINDOWS -> "${homeDirectory}/AppData/Roaming/sosengine-data"
else -> "${homeDirectory}/.sosengine/data" else -> "${homeDirectory}/.sosengine/data"
}).createDirectory() }).createDirectory().verifyIsDirectory()
// Caches // Caches
temporaryCacheDirectory = FileAccess( temporaryCacheDirectory = FileAccess(
System.getProperty("java.io.tmpdir") System.getProperty("java.io.tmpdir")
+ "/sosengine-cache-" + "/sosengine-cache-"
+ ProcessHandle.current().pid() + ProcessHandle.current().pid()
).createDirectory().deleteOnShutdown() ).createDirectory().verifyIsDirectory().deleteOnShutdown()
persistentCacheDirectory = FileAccess(when (Environment.operatingSystem) { persistentCacheDirectory = FileAccess(when (Environment.operatingSystem) {
LINUX, FREEBSD, NETBSD, OPENBSD -> "${homeDirectory}/.cache" LINUX, FREEBSD, NETBSD, OPENBSD -> "${homeDirectory}/.cache"
WINDOWS -> "${homeDirectory}/AppData/Local/Temp" WINDOWS -> "${homeDirectory}/AppData/Local/Temp"
else -> "${homeDirectory}/.sosengine/persistent-cache" else -> "${homeDirectory}/.sosengine/persistent-cache"
}).createDirectory() }).createDirectory().verifyIsDirectory()
} }