1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 08:27:12 -07:00

Minor fixes to the Daniil's timeout checks.

This commit is contained in:
Cedric Beust 2016-01-29 22:59:53 +04:00
parent efd12733ee
commit e441d8bafb
4 changed files with 11 additions and 12 deletions

View file

@ -37,7 +37,7 @@ public class Kobalt {
private val KOBALT_PROPERTIES = "kobalt.properties"
private val PROPERTY_KOBALT_VERSION = "kobalt.version"
private val PROPERTY_KOBALT_VERSION_CHECK_TIMEOUT = "kobalt.version.check_timeout" // ISO-8601
private val PROPERTY_KOBALT_VERSION_CHECK_TIMEOUT = "kobalt.version.checkTimeout" // ISO-8601
/** kobalt.properties */
private val kobaltProperties: Properties by lazy { readProperties() }
@ -75,7 +75,8 @@ public class Kobalt {
}
val version = kobaltProperties.getProperty(PROPERTY_KOBALT_VERSION)
val versionCheckTimeout = Duration.parse(kobaltProperties.getProperty(PROPERTY_KOBALT_VERSION_CHECK_TIMEOUT))
val versionCheckTimeout = Duration.parse(
kobaltProperties.getProperty(PROPERTY_KOBALT_VERSION_CHECK_TIMEOUT) ?: "P1D2H")
fun findPlugin(name: String) = Plugins.findPlugin(name)
}

View file

@ -7,17 +7,16 @@ import java.time.Instant
class VersionCheckTimestampFile {
companion object {
private val KOBALT_VERSION_CHECK_TIMESTAMP_FILE = "versionCheckTimestamp.txt"
private val checkTimestampFile = File(KFiles.KOBALT_DOT_DIR, KOBALT_VERSION_CHECK_TIMESTAMP_FILE)
private val CHECK_TIMESTAMP_FILE = File(KFiles.KOBALT_DOT_DIR, KOBALT_VERSION_CHECK_TIMESTAMP_FILE)
fun updateTimestamp(timestamp: Instant) = KFiles.saveFile(checkTimestampFile, timestamp.toString())
fun updateTimestamp(timestamp: Instant) = KFiles.saveFile(CHECK_TIMESTAMP_FILE, timestamp.toString())
fun getTimestamp(): Instant {
return if(checkTimestampFile.exists())
Instant.parse(checkTimestampFile.readText())
else {
val timestamp : Instant
get() = if (CHECK_TIMESTAMP_FILE.exists()) {
Instant.parse(CHECK_TIMESTAMP_FILE.readText())
} else {
updateTimestamp(Instant.MIN)
Instant.MIN
}
}
}
}