Removed ApiService instance creation in ApplyUpdate as it wasn't really needed, and probably not sensible to instantiate it here.

This commit is contained in:
CalDescent 2022-01-23 12:57:28 +00:00
parent ff6ec83b1c
commit 6f7c8d96b9

View File

@ -15,7 +15,6 @@ import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.jsse.provider.BouncyCastleJsseProvider;
import org.qortal.api.ApiKey;
import org.qortal.api.ApiRequest;
import org.qortal.api.ApiService;
import org.qortal.controller.AutoUpdate;
import org.qortal.settings.Settings;
@ -74,14 +73,11 @@ public class ApplyUpdate {
boolean apiKeyNewlyGenerated = false;
ApiKey apiKey = null;
try {
apiKey = ApiService.getInstance().getApiKey();
if (apiKey == null) {
apiKey = new ApiKey();
if (!apiKey.generated()) {
apiKey.generate();
apiKeyNewlyGenerated = true;
LOGGER.info("Generated API key");
}
apiKey = new ApiKey();
if (!apiKey.generated()) {
apiKey.generate();
apiKeyNewlyGenerated = true;
LOGGER.info("Generated API key");
}
} catch (IOException e) {
LOGGER.info("Error loading API key: {}", e.getMessage());
@ -135,12 +131,8 @@ public class ApplyUpdate {
try {
LOGGER.info("Removing newly generated API key...");
ApiKey apiKey = ApiService.getInstance().getApiKey();
if (apiKey == null) {
apiKey = new ApiKey();
}
// Delete the API key since it was only generated for this auto update
ApiKey apiKey = new ApiKey();
apiKey.delete();
} catch (IOException e) {