Fix migrations of Functions

This commit is contained in:
2020-05-11 01:39:36 +02:00
parent 377459f430
commit 55b547db75
6 changed files with 24 additions and 18 deletions

View File

@@ -5,6 +5,7 @@ import org.slf4j.Logger
import org.slf4j.LoggerFactory
import java.net.URI
import java.net.URL
import java.nio.file.FileSystemNotFoundException
import java.nio.file.FileSystems
import java.nio.file.FileVisitOption
import java.nio.file.Files
@@ -16,11 +17,15 @@ fun URL.searchSqlFiles() = this.toURI().searchSqlFiles()
fun URI.searchSqlFiles() = sequence<Resource> {
val logger: Logger = LoggerFactory.getLogger("sqlFilesSearch")
val uri: URI = this@searchSqlFiles
logger.debug("""SQL files found in "${uri.toString().substringAfter('!')}" :""")
if (uri.scheme == "jar") {
val relativePath = uri.toString().substringAfter('!')
FileSystems
.newFileSystem(uri, emptyMap<String, Any>())
.getPath(relativePath)
try {
FileSystems.getFileSystem(uri)
} catch (e: FileSystemNotFoundException) {
FileSystems.newFileSystem(uri, emptyMap<String, Any>())
}
uri
.walk(5)
.asSequence()
.filter { it.fileName.toString().endsWith(".sql") }