From 3af8e395bd6f48ee7ed39011115dc190fa99a7e0 Mon Sep 17 00:00:00 2001 From: Mitchell Syer Date: Thu, 23 Jan 2025 09:38:52 -0500 Subject: [PATCH] Check if file exists (#1246) --- .../suwayomi/tachidesk/graphql/server/TemporaryFileStorage.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/TemporaryFileStorage.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/TemporaryFileStorage.kt index 0bc4e4c1..d45b634f 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/TemporaryFileStorage.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/TemporaryFileStorage.kt @@ -11,6 +11,7 @@ import kotlin.concurrent.thread import kotlin.io.path.ExperimentalPathApi import kotlin.io.path.deleteIfExists import kotlin.io.path.deleteRecursively +import kotlin.io.path.exists import kotlin.io.path.name import kotlin.io.path.outputStream import kotlin.time.Duration.Companion.days @@ -46,7 +47,7 @@ object TemporaryFileStorage { fun retrieveFile(name: String): Path { val file = folder.resolve(name).normalize() - check(file.startsWith(folder)) { + check(file.startsWith(folder) && file.exists()) { "File $name is not in ${folder.name}" } return file