mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Only check for the latest release version number on GitHub every 10 minutes.
This commit is contained in:
parent
6409e723cb
commit
c342573e55
1 changed files with 38 additions and 29 deletions
|
@ -1,8 +1,10 @@
|
|||
package com.beust.kobalt.misc
|
||||
|
||||
import com.beust.kobalt.KobaltException
|
||||
import com.beust.kobalt.api.Kobalt
|
||||
import com.beust.kobalt.internal.DocUrl
|
||||
import com.beust.kobalt.internal.KobaltSettings
|
||||
import com.beust.kobalt.internal.build.VersionCheckTimestampFile
|
||||
import com.beust.kobalt.maven.Http
|
||||
import com.beust.kobalt.maven.aether.Exceptions
|
||||
import com.google.gson.Gson
|
||||
|
@ -16,6 +18,8 @@ import retrofit2.converter.gson.GsonConverterFactory
|
|||
import retrofit2.http.*
|
||||
import rx.Observable
|
||||
import java.io.File
|
||||
import java.time.Duration
|
||||
import java.time.Instant
|
||||
import java.util.*
|
||||
import java.util.concurrent.Callable
|
||||
import java.util.concurrent.Future
|
||||
|
@ -110,7 +114,11 @@ class GithubApi2 @Inject constructor(
|
|||
get() {
|
||||
val callable = Callable<String> {
|
||||
var result = "0"
|
||||
|
||||
if (Duration.ofMinutes(10L) >
|
||||
Duration.between(VersionCheckTimestampFile.timestamp, Instant.now())) {
|
||||
kobaltLog(2, "Skipping GitHub latest release check, too soon.")
|
||||
result = Kobalt.version
|
||||
} else {
|
||||
val username = localProperties.getNoThrows(PROPERTY_USERNAME, DOC_URL)
|
||||
val accessToken = localProperties.getNoThrows(PROPERTY_ACCESS_TOKEN, DOC_URL)
|
||||
try {
|
||||
|
@ -153,6 +161,7 @@ class GithubApi2 @Inject constructor(
|
|||
// kobaltLog(2, "Couldn't retrieve releases from github, ${error.message ?: e}: "
|
||||
// + details?.code + " field: " + details?.field)
|
||||
}
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue