From 5c690d722aa5adf9bc644055574d86c987832238 Mon Sep 17 00:00:00 2001 From: DNx5 Date: Wed, 1 Jun 2016 05:23:40 +0700 Subject: [PATCH] - do the check for old GeoLite data correctly. --- .../java/fr/xephi/authme/util/GeoLiteAPI.java | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/main/java/fr/xephi/authme/util/GeoLiteAPI.java b/src/main/java/fr/xephi/authme/util/GeoLiteAPI.java index 835940869..49a57cf3c 100644 --- a/src/main/java/fr/xephi/authme/util/GeoLiteAPI.java +++ b/src/main/java/fr/xephi/authme/util/GeoLiteAPI.java @@ -39,18 +39,21 @@ public class GeoLiteAPI { } final File pluginFolder = AuthMe.getInstance().getDataFolder(); final File data = new File(pluginFolder, "GeoIP.dat"); - boolean dataIsOld = (System.currentTimeMillis() - data.lastModified()) > TimeUnit.DAYS.toMillis(30); - if (dataIsOld && !data.delete()) { - ConsoleLogger.showError("Failed to delete GeoLiteAPI database"); - } if (data.exists()) { - try { - lookupService = new LookupService(data); - ConsoleLogger.info(LICENSE); - return true; - } catch (IOException e) { - ConsoleLogger.logException("Failed to load GeoLiteAPI database", e); - return false; + boolean dataIsOld = (System.currentTimeMillis() - data.lastModified()) > TimeUnit.DAYS.toMillis(30); + if (!dataIsOld) { + try { + lookupService = new LookupService(data); + ConsoleLogger.info(LICENSE); + return true; + } catch (IOException e) { + ConsoleLogger.logException("Failed to load GeoLiteAPI database", e); + return false; + } + } else { + if (!data.delete()) { + ConsoleLogger.showError("Failed to delete GeoLiteAPI database"); + } } } // Ok, let's try to download the data file!