Do not check for update of authlib-injector each time
This commit is contained in:
@@ -45,6 +45,11 @@ public class AuthlibInjectorDownloader {
|
||||
private Path artifactLocation;
|
||||
private Supplier<DownloadProvider> downloadProvider;
|
||||
|
||||
/**
|
||||
* The flag will be reset after application restart.
|
||||
*/
|
||||
private boolean updateChecked = false;
|
||||
|
||||
/**
|
||||
* @param artifactsDirectory where to save authlib-injector artifacts
|
||||
*/
|
||||
@@ -57,8 +62,10 @@ public class AuthlibInjectorDownloader {
|
||||
synchronized (artifactLocation) {
|
||||
Optional<AuthlibInjectorArtifactInfo> local = getLocalArtifact();
|
||||
|
||||
if (!local.isPresent() || !updateChecked) {
|
||||
try {
|
||||
update(local);
|
||||
updateChecked = true;
|
||||
} catch (IOException e) {
|
||||
LOG.log(Level.WARNING, "Failed to download authlib-injector", e);
|
||||
if (!local.isPresent()) {
|
||||
@@ -66,12 +73,14 @@ public class AuthlibInjectorDownloader {
|
||||
}
|
||||
LOG.warning("Fallback to use cached artifact: " + local.get());
|
||||
}
|
||||
}
|
||||
|
||||
return getLocalArtifact().orElseThrow(() -> new IOException("The updated authlib-inejector cannot be recognized"));
|
||||
}
|
||||
}
|
||||
|
||||
private void update(Optional<AuthlibInjectorArtifactInfo> local) throws IOException {
|
||||
LOG.info("Checking update of authlib-injector");
|
||||
AuthlibInjectorVersionInfo latest = getLatestArtifactInfo();
|
||||
|
||||
if (local.isPresent() && local.get().getBuildNumber() >= latest.buildNumber) {
|
||||
|
||||
Reference in New Issue
Block a user