- do the check for old GeoLite data correctly.

This commit is contained in:
DNx5 2016-06-01 05:23:40 +07:00
parent 10e5ae08e2
commit 5c690d722a

View File

@ -39,18 +39,21 @@ public class GeoLiteAPI {
} }
final File pluginFolder = AuthMe.getInstance().getDataFolder(); final File pluginFolder = AuthMe.getInstance().getDataFolder();
final File data = new File(pluginFolder, "GeoIP.dat"); 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()) { if (data.exists()) {
try { boolean dataIsOld = (System.currentTimeMillis() - data.lastModified()) > TimeUnit.DAYS.toMillis(30);
lookupService = new LookupService(data); if (!dataIsOld) {
ConsoleLogger.info(LICENSE); try {
return true; lookupService = new LookupService(data);
} catch (IOException e) { ConsoleLogger.info(LICENSE);
ConsoleLogger.logException("Failed to load GeoLiteAPI database", e); return true;
return false; } 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! // Ok, let's try to download the data file!