Ensure etags.json can update when empty (#182)
* Ensure etags.json can update when empty * Update and load etags on settings change * Handle exception in catch block
This commit is contained in:
parent
f4fc9d6328
commit
85295ea62c
2 changed files with 7 additions and 1 deletions
|
|
@ -6,6 +6,7 @@ const path = require('path')
|
||||||
const util = require('util')
|
const util = require('util')
|
||||||
const options = require('../options')
|
const options = require('../options')
|
||||||
const _ = require('lodash/fp')
|
const _ = require('lodash/fp')
|
||||||
|
const logger = require('../logger')
|
||||||
|
|
||||||
const DOWNLOAD_DIR = path.resolve('/tmp')
|
const DOWNLOAD_DIR = path.resolve('/tmp')
|
||||||
|
|
||||||
|
|
@ -114,7 +115,11 @@ function update () {
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const promiseOldEtags = readFile(OFAC_ETAGS_FILE, {encoding: 'utf-8'})
|
const promiseOldEtags = readFile(OFAC_ETAGS_FILE, {encoding: 'utf-8'})
|
||||||
.then(json => JSON.parse(json) || {})
|
.then(json => JSON.parse(json))
|
||||||
|
.catch(_ => {
|
||||||
|
logger.error('Can\'t parse etags.json, getting new data...')
|
||||||
|
return {}
|
||||||
|
})
|
||||||
|
|
||||||
const promiseNewEtags = Promise.resolve(options.ofacSources || [])
|
const promiseNewEtags = Promise.resolve(options.ofacSources || [])
|
||||||
.then(sources => Promise.all(_.map(promiseGetEtag, sources))
|
.then(sources => Promise.all(_.map(promiseGetEtag, sources))
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ function reload (__settings) {
|
||||||
_settings = __settings
|
_settings = __settings
|
||||||
_pi = plugins(_settings)
|
_pi = plugins(_settings)
|
||||||
logger.debug('settings reloaded in poller')
|
logger.debug('settings reloaded in poller')
|
||||||
|
updateAndLoadSanctions()
|
||||||
}
|
}
|
||||||
|
|
||||||
function pi () { return _pi }
|
function pi () { return _pi }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue