Added revalidate_policy config.
This allows resources to be validated prior to every app launch instead of just after update. Also fixed some erroneous logging.
This commit is contained in:
@@ -18,6 +18,11 @@
|
|||||||
without a proxy, it does so for that session, but retains the proxy config for future sessions in
|
without a proxy, it does so for that session, but retains the proxy config for future sessions in
|
||||||
which the proxy may again be needed.
|
which the proxy may again be needed.
|
||||||
|
|
||||||
|
* Added `revalidate_policy` config to control when Getdown revalidates resources (by hashing them
|
||||||
|
and comparing that hash to the values in `digest.txt`). The default, `after_update`, only
|
||||||
|
validates resources after the app is updated. A new mode, `always`, validates resources prior to
|
||||||
|
every application launch.
|
||||||
|
|
||||||
## 1.8.4 - May 14, 2019
|
## 1.8.4 - May 14, 2019
|
||||||
|
|
||||||
* Added `verify_timeout` config to allow customization of the default (60 second) timeout during
|
* Added `verify_timeout` config to allow customization of the default (60 second) timeout during
|
||||||
|
|||||||
@@ -636,21 +636,18 @@ public class Application
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// determine whether we want strict comments
|
// read some miscellaneous configurations
|
||||||
_strictComments = config.getBoolean("strict_comments");
|
_strictComments = config.getBoolean("strict_comments");
|
||||||
|
|
||||||
// determine whether we want to allow offline operation (defaults to false)
|
|
||||||
_allowOffline = config.getBoolean("allow_offline");
|
_allowOffline = config.getBoolean("allow_offline");
|
||||||
|
_revalidatePolicy = config.getEnum(
|
||||||
|
"revalidate_policy", RevalidatePolicy.class, RevalidatePolicy.AFTER_UPDATE);
|
||||||
|
int tpSize = SysProps.threadPoolSize();
|
||||||
|
_maxConcDownloads = Math.max(1, config.getInt("max_concurrent_downloads", tpSize));
|
||||||
|
_verifyTimeout = config.getInt("verify_timeout", 60);
|
||||||
|
|
||||||
// whether to cache code resources and launch from cache
|
// whether to cache code resources and launch from cache
|
||||||
_useCodeCache = config.getBoolean("use_code_cache");
|
_useCodeCache = config.getBoolean("use_code_cache");
|
||||||
_codeCacheRetentionDays = config.getInt("code_cache_retention_days", 7);
|
_codeCacheRetentionDays = config.getInt("code_cache_retention_days", 7);
|
||||||
|
|
||||||
// maximum simultaneous downloads
|
|
||||||
_maxConcDownloads = Math.max(1, config.getInt("max_concurrent_downloads",
|
|
||||||
SysProps.threadPoolSize()));
|
|
||||||
|
|
||||||
_verifyTimeout = config.getInt("verify_timeout", 60);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1361,14 +1358,14 @@ public class Application
|
|||||||
unpacked.addAll(unpackedAsync);
|
unpacked.addAll(unpackedAsync);
|
||||||
|
|
||||||
long complete = System.currentTimeMillis();
|
long complete = System.currentTimeMillis();
|
||||||
log.info("Verified resources", "count", rsrcs.size(), "size", (totalSize/1024) + "k",
|
log.info("Verified resources", "count", rsrcs.size(), "alreadyValid", alreadyValid[0],
|
||||||
"duration", (complete-start) + "ms");
|
"size", (totalSize/1024) + "k", "duration", (complete-start) + "ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyResource (Resource rsrc, ProgressObserver obs, int[] alreadyValid,
|
private void verifyResource (Resource rsrc, ProgressObserver obs, int[] alreadyValid,
|
||||||
Set<Resource> unpacked,
|
Set<Resource> unpacked,
|
||||||
Set<Resource> toInstall, Set<Resource> toDownload) {
|
Set<Resource> toInstall, Set<Resource> toDownload) {
|
||||||
if (rsrc.isMarkedValid()) {
|
if (_revalidatePolicy != RevalidatePolicy.ALWAYS && rsrc.isMarkedValid()) {
|
||||||
if (alreadyValid != null) {
|
if (alreadyValid != null) {
|
||||||
alreadyValid[0]++;
|
alreadyValid[0]++;
|
||||||
}
|
}
|
||||||
@@ -1765,6 +1762,7 @@ public class Application
|
|||||||
|
|
||||||
protected int _verifyTimeout = 60;
|
protected int _verifyTimeout = 60;
|
||||||
|
|
||||||
|
protected RevalidatePolicy _revalidatePolicy = RevalidatePolicy.AFTER_UPDATE;
|
||||||
protected boolean _useCodeCache;
|
protected boolean _useCodeCache;
|
||||||
protected int _codeCacheRetentionDays;
|
protected int _codeCacheRetentionDays;
|
||||||
|
|
||||||
@@ -1790,4 +1788,6 @@ public class Application
|
|||||||
|
|
||||||
protected static final String ENV_VAR_PREFIX = "%ENV.";
|
protected static final String ENV_VAR_PREFIX = "%ENV.";
|
||||||
protected static final Pattern ENV_VAR_PATTERN = Pattern.compile("%ENV\\.(.*?)%");
|
protected static final Pattern ENV_VAR_PATTERN = Pattern.compile("%ENV\\.(.*?)%");
|
||||||
|
|
||||||
|
protected static enum RevalidatePolicy { ALWAYS, AFTER_UPDATE }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -247,6 +247,20 @@ public class Config
|
|||||||
return Boolean.parseBoolean(getString(name));
|
return Boolean.parseBoolean(getString(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the specified config value as an enum value. The string value of the config is
|
||||||
|
* converted to all upper case and then turned into an enum via {@link Enum#valueOf}.
|
||||||
|
*/
|
||||||
|
public <T extends Enum<T>> T getEnum (String name, Class<T> eclass, T defval) {
|
||||||
|
String value = getString(name, defval.toString());
|
||||||
|
try {
|
||||||
|
return Enum.valueOf(eclass, value.toUpperCase());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warning("Invalid value for '" + name + "' config: '" + value + "'.");
|
||||||
|
return defval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Massages a single string into an array and leaves existing array values as is. Simplifies
|
* Massages a single string into an array and leaves existing array values as is. Simplifies
|
||||||
* access to parameters that are expected to be arrays.
|
* access to parameters that are expected to be arrays.
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ public abstract class Getdown
|
|||||||
{
|
{
|
||||||
if (SysProps.noInstall()) {
|
if (SysProps.noInstall()) {
|
||||||
log.info("Skipping install due to 'no_install' sysprop.");
|
log.info("Skipping install due to 'no_install' sysprop.");
|
||||||
} else if (_readyToInstall) {
|
} else if (isUpdateAvailable()) {
|
||||||
log.info("Installing " + _toInstallResources.size() + " downloaded resources:");
|
log.info("Installing " + _toInstallResources.size() + " downloaded resources:");
|
||||||
for (Resource resource : _toInstallResources) {
|
for (Resource resource : _toInstallResources) {
|
||||||
resource.install(true);
|
resource.install(true);
|
||||||
@@ -260,13 +260,15 @@ public abstract class Getdown
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
if (!predownloads.isEmpty()) {
|
||||||
download(predownloads);
|
try {
|
||||||
for (Resource rsrc : predownloads) {
|
download(predownloads);
|
||||||
rsrc.install(false); // install but don't validate yet
|
for (Resource rsrc : predownloads) {
|
||||||
|
rsrc.install(false); // install but don't validate yet
|
||||||
|
}
|
||||||
|
} catch (IOException ioe) {
|
||||||
|
log.warning("Failed to predownload resources. Continuing...", ioe);
|
||||||
}
|
}
|
||||||
} catch (IOException ioe) {
|
|
||||||
log.warning("Failed to predownload resources. Continuing...", ioe);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user