Search in sources :

Example 1 with HydraTask

use of org.nzbhydra.tasks.HydraTask in project nzbhydra2 by theotherp.

the class IndexerStatusesCleanupTask method cleanup.

@HydraTask(configId = "cleanUpIndexerStatuses", name = "Clean up indexer statuses", interval = MINUTE)
public void cleanup() {
    for (IndexerConfig config : configProvider.getBaseConfig().getIndexers()) {
        if (config.getState() == IndexerConfig.State.DISABLED_SYSTEM_TEMPORARY && config.getDisabledUntil() != null && Instant.ofEpochMilli(config.getDisabledUntil()).isBefore(Instant.now())) {
            // Do not reset the level. When the indexer is called the next time (when disabledUntil is in the past)
            // and an error occurs the level is increased and the indexer gets disabled for a longer time
            logger.debug("Setting indexer {} back to enabled after having been temporarily disabled until {}", config.getName(), Instant.ofEpochMilli(config.getDisabledUntil()));
            config.setState(IndexerConfig.State.ENABLED);
            config.setDisabledUntil(null);
            config.setLastError(null);
        }
    }
    configProvider.getBaseConfig().saveInternal();
}
Also used : IndexerConfig(org.nzbhydra.config.IndexerConfig) HydraTask(org.nzbhydra.tasks.HydraTask)

Aggregations

IndexerConfig (org.nzbhydra.config.IndexerConfig)1 HydraTask (org.nzbhydra.tasks.HydraTask)1