add the other getProperty(); more tweaks

This commit is contained in:
zzz
2012-10-18 21:07:36 +00:00
parent 0b4401e64b
commit 4f936f958d
5 changed files with 27 additions and 12 deletions

View File

@ -1097,7 +1097,7 @@ public class ConsoleUpdateManager implements UpdateManager {
@Override @Override
public String toString() { public String toString() {
return "RegisteredUpdater " + updater + " for " + type + ' ' + method + " @pri " + priority; return "RegisteredUpdater " + updater.getClass().getSimpleName() + " for " + type + ' ' + method + " @pri " + priority;
} }
} }
@ -1138,7 +1138,7 @@ public class ConsoleUpdateManager implements UpdateManager {
@Override @Override
public String toString() { public String toString() {
return "RegisteredChecker " + checker + " for " + type + ' ' + method + " @pri " + priority; return "RegisteredChecker " + checker.getClass().getSimpleName() + " for " + type + ' ' + method + " @pri " + priority;
} }
} }

View File

@ -97,15 +97,10 @@ class NewsFetcher extends UpdateRunner {
else else
get = new EepGet(_context, false, null, 0, 0, _tempFile.getAbsolutePath(), newsURL, true, null, _lastModified); get = new EepGet(_context, false, null, 0, 0, _tempFile.getAbsolutePath(), newsURL, true, null, _lastModified);
get.addStatusListener(this); get.addStatusListener(this);
long start = _context.clock().now();
if (get.fetch()) { if (get.fetch()) {
String lastMod = get.getLastModified(); _context.router().saveConfig(NewsHelper.PROP_LAST_CHECKED,
if (lastMod != null) { Long.toString(start));
_lastModified = lastMod;
long lm = RFC822Date.parse822Date(lastMod);
if (lm == 0)
lm = _context.clock().now();
_context.router().saveConfig(NewsHelper.PROP_LAST_CHECKED, Long.toString(lm));
}
return; return;
} }
} catch (Throwable t) { } catch (Throwable t) {

View File

@ -125,7 +125,7 @@ public class NewsHelper extends ContentHelper {
* @since 0.9.4 * @since 0.9.4
*/ */
public static boolean shouldShowNews(RouterContext ctx) { public static boolean shouldShowNews(RouterContext ctx) {
long lastUpdated = lastUpdated(ctx); long lastUpdated = lastUpdated(ctx);
if (lastUpdated <= 0) if (lastUpdated <= 0)
return true; return true;
long last = ctx.getProperty(PROP_LAST_HIDDEN, 0L); long last = ctx.getProperty(PROP_LAST_HIDDEN, 0L);

View File

@ -13,5 +13,6 @@ public enum UpdateType {
ROUTER_UNSIGNED, ROUTER_UNSIGNED,
PLUGIN, PLUGIN_INSTALL, PLUGIN, PLUGIN_INSTALL,
GEOIP, BLOCKLIST, RESEED, GEOIP, BLOCKLIST, RESEED,
HOMEPAGE HOMEPAGE,
ADDRESSBOOK
} }

View File

@ -416,6 +416,25 @@ public class RouterContext extends I2PAppContext {
return super.getProperty(propName, defaultVal); return super.getProperty(propName, defaultVal);
} }
/**
* Return a long with a long default
* @since 0.9.4
*/
@Override
public long getProperty(String propName, long defaultVal) {
if (_router != null) {
String val = _router.getConfigSetting(propName);
if (val != null) {
long rv = defaultVal;
try {
rv = Long.parseLong(val);
} catch (NumberFormatException nfe) {}
return rv;
}
}
return super.getProperty(propName, defaultVal);
}
/** /**
* @return new Properties with system and context properties * @return new Properties with system and context properties
* @since 0.8.4 * @since 0.8.4