diff --git a/CommonCore/SQL/src/de/steamwar/sql/NodeDownload.kt b/CommonCore/SQL/src/de/steamwar/sql/NodeDownload.kt index adb25b90..62de6038 100644 --- a/CommonCore/SQL/src/de/steamwar/sql/NodeDownload.kt +++ b/CommonCore/SQL/src/de/steamwar/sql/NodeDownload.kt @@ -25,6 +25,7 @@ import org.jetbrains.exposed.v1.core.dao.id.IdTable import org.jetbrains.exposed.v1.core.eq import org.jetbrains.exposed.v1.dao.IntEntity import org.jetbrains.exposed.v1.dao.IntEntityClass +import org.jetbrains.exposed.v1.javatime.CurrentTimestamp import org.jetbrains.exposed.v1.javatime.timestamp import java.security.MessageDigest import java.sql.Timestamp @@ -33,7 +34,7 @@ import java.time.Instant object NodeDownloadTable: IdTable("NodeDownload") { override val id = reference("NodeId", SchematicNodeTable).uniqueIndex() val link = varchar("Link", 255) - val timestamp = timestamp("Timestamp").default(Instant.now()) + val timestamp = timestamp("Timestamp").defaultExpression(CurrentTimestamp) } class NodeDownload(id: EntityID) : IntEntity(id) { @@ -49,7 +50,9 @@ class NodeDownload(id: EntityID) : IntEntity(id) { digest.update("${Instant.now()}${schem.owner}${schem.nodeId}".toByteArray()) val hash = digest.digest().joinToString("") { "%02x".format(it) } useDb { - new { + findByIdAndUpdate(schem.id.value) { + it.link = hash + } ?: new { nodeId = schem.id.value link = hash }