|
|
@ -52,6 +52,7 @@ import java.time.ZoneOffset |
|
|
|
import java.util.jar.JarInputStream |
|
|
|
import java.util.jar.JarInputStream |
|
|
|
import java.util.jar.JarOutputStream |
|
|
|
import java.util.jar.JarOutputStream |
|
|
|
import java.util.jar.Pack200 |
|
|
|
import java.util.jar.Pack200 |
|
|
|
|
|
|
|
import kotlin.io.path.getLastModifiedTime |
|
|
|
|
|
|
|
|
|
|
|
@Singleton |
|
|
|
@Singleton |
|
|
|
public class ClientImporter @Inject constructor( |
|
|
|
public class ClientImporter @Inject constructor( |
|
|
@ -72,12 +73,26 @@ public class ClientImporter @Inject constructor( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
logger.info { "Importing $path" } |
|
|
|
logger.info { "Importing $path" } |
|
|
|
import(parse(buf), name, description, url) |
|
|
|
import( |
|
|
|
|
|
|
|
parse(buf), |
|
|
|
|
|
|
|
name, |
|
|
|
|
|
|
|
description, |
|
|
|
|
|
|
|
url, |
|
|
|
|
|
|
|
path.fileName.toString(), |
|
|
|
|
|
|
|
path.getLastModifiedTime().toInstant() |
|
|
|
|
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public suspend fun import(artifact: Artifact, name: String?, description: String?, url: String?) { |
|
|
|
public suspend fun import( |
|
|
|
|
|
|
|
artifact: Artifact, |
|
|
|
|
|
|
|
name: String?, |
|
|
|
|
|
|
|
description: String?, |
|
|
|
|
|
|
|
url: String?, |
|
|
|
|
|
|
|
fileName: String, |
|
|
|
|
|
|
|
timestamp: Instant |
|
|
|
|
|
|
|
) { |
|
|
|
database.execute { connection -> |
|
|
|
database.execute { connection -> |
|
|
|
importer.prepare(connection) |
|
|
|
importer.prepare(connection) |
|
|
|
|
|
|
|
|
|
|
@ -85,14 +100,16 @@ public class ClientImporter @Inject constructor( |
|
|
|
|
|
|
|
|
|
|
|
connection.prepareStatement( |
|
|
|
connection.prepareStatement( |
|
|
|
""" |
|
|
|
""" |
|
|
|
INSERT INTO artifact_sources (blob_id, name, description, url) |
|
|
|
INSERT INTO artifact_sources (blob_id, name, description, url, file_name, timestamp) |
|
|
|
VALUES (?, ?, ?, ?) |
|
|
|
VALUES (?, ?, ?, ?, ?, ?) |
|
|
|
""".trimIndent() |
|
|
|
""".trimIndent() |
|
|
|
).use { stmt -> |
|
|
|
).use { stmt -> |
|
|
|
stmt.setLong(1, id) |
|
|
|
stmt.setLong(1, id) |
|
|
|
stmt.setString(2, name) |
|
|
|
stmt.setString(2, name) |
|
|
|
stmt.setString(3, description) |
|
|
|
stmt.setString(3, description) |
|
|
|
stmt.setString(4, url) |
|
|
|
stmt.setString(4, url) |
|
|
|
|
|
|
|
stmt.setString(5, fileName) |
|
|
|
|
|
|
|
stmt.setObject(6, timestamp.atOffset(ZoneOffset.UTC), Types.TIMESTAMP_WITH_TIMEZONE) |
|
|
|
|
|
|
|
|
|
|
|
stmt.execute() |
|
|
|
stmt.execute() |
|
|
|
} |
|
|
|
} |
|
|
|