diff --git a/bubble-server/src/main/java/bubble/cloud/geoLocation/GeoLocateServiceDriverBase.java b/bubble-server/src/main/java/bubble/cloud/geoLocation/GeoLocateServiceDriverBase.java index 82ccfd0e..2d2a8249 100644 --- a/bubble-server/src/main/java/bubble/cloud/geoLocation/GeoLocateServiceDriverBase.java +++ b/bubble-server/src/main/java/bubble/cloud/geoLocation/GeoLocateServiceDriverBase.java @@ -18,13 +18,16 @@ import org.cobbzilla.wizard.cache.redis.RedisService; import org.springframework.beans.factory.annotation.Autowired; import java.io.File; +import java.io.IOException; import java.util.List; import java.util.concurrent.TimeUnit; import java.util.regex.Pattern; +import static java.util.concurrent.TimeUnit.SECONDS; import static org.cobbzilla.util.daemon.ZillaRuntime.*; import static org.cobbzilla.util.io.FileUtil.*; import static org.cobbzilla.util.json.JsonUtil.json; +import static org.cobbzilla.util.system.Sleep.sleep; import static org.cobbzilla.wizard.cache.redis.RedisService.EX; import static org.cobbzilla.wizard.resources.ResourceUtil.invalidEx; @@ -32,7 +35,9 @@ import static org.cobbzilla.wizard.resources.ResourceUtil.invalidEx; public abstract class GeoLocateServiceDriverBase extends CloudServiceDriverBase implements GeoLocateServiceDriver { public static final long CACHE_TTL = TimeUnit.DAYS.toSeconds(20); - public static final long ERROR_TTL = TimeUnit.SECONDS.toSeconds(20); + public static final long ERROR_TTL = SECONDS.toSeconds(20); + + private static final int MAX_FILE_RETRIES = 5; private static class GeoLocationError extends GeoLocation { public GeoLocationError(Exception e) { @@ -82,7 +87,7 @@ public abstract class GeoLocateServiceDriverBase extends CloudServiceDriverBa final String key = "urlcache_" + uniq; final File archive = cloudDataDAO.getFile(cloud.getUuid(), key); if (meta.shouldRefresh(archive)) { - HttpUtil.getResponse(request).toFile(archive); + downloadDbFile(request, archive); } // create a symlink with the proper extension, so "unroll" can detect the archive type @@ -109,6 +114,22 @@ public abstract class GeoLocateServiceDriverBase extends CloudServiceDriverBa } } + private File downloadDbFile(HttpRequestBean request, File archive) throws IOException { + File file = null; + RuntimeException lastEx = null; + for (int i=0; i