mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-27 08:38:13 -07:00
moved the waiting operation under the timeout check
This commit is contained in:
parent
ac968cef99
commit
6ad374006f
2 changed files with 8 additions and 3 deletions
|
@ -81,6 +81,7 @@ private class Main @Inject constructor(
|
||||||
|
|
||||||
var result = 0
|
var result = 0
|
||||||
val latestVersionFuture = github.latestKobaltVersion
|
val latestVersionFuture = github.latestKobaltVersion
|
||||||
|
|
||||||
val seconds = benchmarkSeconds {
|
val seconds = benchmarkSeconds {
|
||||||
try {
|
try {
|
||||||
result = runWithArgs(jc, args, argv)
|
result = runWithArgs(jc, args, argv)
|
||||||
|
@ -95,8 +96,7 @@ private class Main @Inject constructor(
|
||||||
if (! args.update) {
|
if (! args.update) {
|
||||||
log(1, if (result != 0) "BUILD FAILED: $result" else "BUILD SUCCESSFUL ($seconds seconds)")
|
log(1, if (result != 0) "BUILD FAILED: $result" else "BUILD SUCCESSFUL ($seconds seconds)")
|
||||||
|
|
||||||
// Check for new version
|
updateKobalt.checkForNewVersion(latestVersionFuture)
|
||||||
updateKobalt.checkForNewVersion(latestVersionFuture.get())
|
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.beust.kobalt.wrapper.Main
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.time.Duration
|
import java.time.Duration
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
import java.util.concurrent.Future
|
||||||
import java.util.concurrent.TimeoutException
|
import java.util.concurrent.TimeoutException
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
@ -26,12 +27,16 @@ public class UpdateKobalt @Inject constructor(val github: GithubApi, val wrapper
|
||||||
Main.main(arrayOf("--download", "--no-launch"))
|
Main.main(arrayOf("--download", "--no-launch"))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun checkForNewVersion(latestVersionString: String) {
|
/**
|
||||||
|
* Accepts Future<String> as `latestVersionFuture` to allow getting `latestVersion` in the background
|
||||||
|
* */
|
||||||
|
fun checkForNewVersion(latestVersionFuture: Future<String>) {
|
||||||
if(Kobalt.versionCheckTimeout
|
if(Kobalt.versionCheckTimeout
|
||||||
> Duration.between(wrapperProperties.versionLastChecked, Instant.now()))
|
> Duration.between(wrapperProperties.versionLastChecked, Instant.now()))
|
||||||
return // waits `Kobalt.versionCheckTimeout` before the next check
|
return // waits `Kobalt.versionCheckTimeout` before the next check
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
val latestVersionString = latestVersionFuture.get()
|
||||||
val latestVersion = Versions.toLongVersion(latestVersionString)
|
val latestVersion = Versions.toLongVersion(latestVersionString)
|
||||||
val current = Versions.toLongVersion(Kobalt.version)
|
val current = Versions.toLongVersion(Kobalt.version)
|
||||||
val distFile = File(KFiles.joinDir(KFiles.distributionsDir, latestVersionString))
|
val distFile = File(KFiles.joinDir(KFiles.distributionsDir, latestVersionString))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue