Skip to content

Commit

Permalink
fix: Fixed an error when starting the plugin for the first time
Browse files Browse the repository at this point in the history
  • Loading branch information
4drian3d committed Dec 22, 2023
1 parent d2c04ea commit 943d0d4
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public GeoManager(EpicGuard epicGuard) {
try {
if (epicGuard.config().misc().geoDatabaseDownload()) {
final String geoIpKey = epicGuard.config().misc().getGeoDatabaseKey();
if (geoIpKey.isBlank()) {
return;
}
this.downloadDatabase(
countryDatabase,
countryArchive,
Expand All @@ -75,6 +78,7 @@ public GeoManager(EpicGuard epicGuard) {

} else {
epicGuard.logger().info("GeoIP database download is disabled, skipping...");
return;
}

this.countryReader = new DatabaseReader.Builder(countryDatabase.toFile()).withCache(new CHMCache()).build();
Expand All @@ -93,7 +97,7 @@ private void downloadDatabase(@NotNull Path database, @NotNull Path archive, @No
this.epicGuard.logger().info("Extracting the database from the tar archive...");
try (var tarInput = new TarArchiveInputStream(new GZIPInputStream(Files.newInputStream(archive)))) {
TarArchiveEntry entry;
while ((entry = tarInput.getNextTarEntry()) != null) {
while ((entry = tarInput.getNextEntry()) != null) {
// Extracting the database (.mmdb) database we are looking for.
if (entry.getName().endsWith(database.getFileName().toString())) {
Files.copy(tarInput, database, StandardCopyOption.REPLACE_EXISTING);
Expand Down

0 comments on commit 943d0d4

Please sign in to comment.