only update last checked after updates were performed without errors

This commit is contained in:
Jeremy Long
2016-06-05 06:45:13 -04:00
parent 52f269a289
commit a2187205e0

View File

@@ -79,6 +79,7 @@ public class NvdCveUpdater extends BaseUpdater implements CachedWebDataSource {
if (updateable.isUpdateNeeded()) { if (updateable.isUpdateNeeded()) {
performUpdate(updateable); performUpdate(updateable);
} }
getProperties().save(DatabaseProperties.LAST_CHECKED, Long.toString(System.currentTimeMillis()));
} }
} catch (MalformedURLException ex) { } catch (MalformedURLException ex) {
LOGGER.warn( LOGGER.warn(
@@ -115,9 +116,7 @@ public class NvdCveUpdater extends BaseUpdater implements CachedWebDataSource {
final long lastChecked = Long.parseLong(getProperties().getProperty(DatabaseProperties.LAST_CHECKED, "0")); final long lastChecked = Long.parseLong(getProperties().getProperty(DatabaseProperties.LAST_CHECKED, "0"));
final long now = System.currentTimeMillis(); final long now = System.currentTimeMillis();
proceed = (now - lastChecked) > msValid; proceed = (now - lastChecked) > msValid;
if (proceed) { if (!proceed) {
getProperties().save(DatabaseProperties.LAST_CHECKED, Long.toString(now));
} else {
LOGGER.info("Skipping NVD check since last check was within {} hours.", validForHours); LOGGER.info("Skipping NVD check since last check was within {} hours.", validForHours);
LOGGER.debug("Last NVD was at {}, and now {} is within {} ms.", LOGGER.debug("Last NVD was at {}, and now {} is within {} ms.",
lastChecked, now, msValid); lastChecked, now, msValid);
@@ -339,5 +338,4 @@ public class NvdCveUpdater extends BaseUpdater implements CachedWebDataSource {
} }
return updates; return updates;
} }
} }