Normalize Paths (#1245)

* Normalize Paths

* Formatting

* Different format
This commit is contained in:
Mitchell Syer
2025-01-23 09:36:10 -05:00
committed by GitHub
parent fb8f20f31a
commit 0b192cfa52
10 changed files with 150 additions and 121 deletions

View File

@@ -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.name
import kotlin.io.path.outputStream
import kotlin.time.Duration.Companion.days
@@ -43,5 +44,11 @@ object TemporaryFileStorage {
}
}
fun retrieveFile(name: String): Path = folder.resolve(name)
fun retrieveFile(name: String): Path {
val file = folder.resolve(name).normalize()
check(file.startsWith(folder)) {
"File $name is not in ${folder.name}"
}
return file
}
}