mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-28 13:15:28 +01:00
Remove data file if older than 30 days
This commit is contained in:
parent
7b8e5f8e4f
commit
64688c7ae6
@ -12,6 +12,7 @@ import java.io.OutputStream;
|
|||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
public class GeoLiteAPI {
|
public class GeoLiteAPI {
|
||||||
@ -35,6 +36,10 @@ public class GeoLiteAPI {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
final File data = new File(Settings.PLUGIN_FOLDER, "GeoLite2-Country.mmdb");
|
final File data = new File(Settings.PLUGIN_FOLDER, "GeoLite2-Country.mmdb");
|
||||||
|
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 {
|
try {
|
||||||
databaseReader = new DatabaseReader.Builder(data).build();
|
databaseReader = new DatabaseReader.Builder(data).build();
|
||||||
|
Loading…
Reference in New Issue
Block a user