ldn-inbox-server
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -20,3 +20,3 @@ #!/usr/bin/env node | ||
.name('lnd-inbox-server') | ||
.version('1.1.3') | ||
.version('1.1.4') | ||
.description('A demonstration Event Notifications Inbox server'); | ||
@@ -23,0 +23,0 @@ |
@@ -7,3 +7,3 @@ const fs = require('fs'); | ||
logger.info(`parsing notification ${path}`); | ||
throw Error('eeee'); | ||
try { | ||
@@ -10,0 +10,0 @@ const json = JSON.parse(fs.readFileSync(path, { encoding: 'utf-8'})); |
@@ -20,29 +20,35 @@ const fs = require('fs'); | ||
fs.readdir(path, (err,files) => { | ||
files.forEach( (file) => { | ||
const fullPath = `${path}/${file}`; | ||
if (file.match(glob)) { | ||
// Process | ||
lockfile.lock(fullPath) | ||
.then( async (release) => { | ||
try { | ||
await handler(fullPath,options); | ||
} | ||
catch (e) { | ||
logger.error(e); | ||
logger.error(`handler failed on ${fullPath}`); | ||
} | ||
return release(); | ||
}) | ||
.catch( (e) => { | ||
// Need some more elegant code here to select of batch of files to | ||
// process in the path. The code below will work as long as the | ||
// number of files in the inbox don't become gigantic... | ||
const files = fs.readdirSync(path); | ||
for (let i = 0 ; i < files.length ; i++) { | ||
const file = files[i]; | ||
const fullPath = `${path}/${file}`; | ||
if (file.match(glob)) { | ||
// Process | ||
lockfile.lock(fullPath) | ||
.then( async (release) => { | ||
try { | ||
await handler(fullPath,options); | ||
} | ||
catch (e) { | ||
logger.error(e); | ||
logger.warn(`${fullPath} is locked`); | ||
}) | ||
.finally( () => { | ||
logger.error(`handler failed on ${fullPath}`); | ||
} | ||
return release(); | ||
}) | ||
.catch( (e) => { | ||
logger.debug(`${fullPath} is locked`); | ||
}) | ||
.finally( () => { | ||
if (fs.existsSync(fullPath)) { | ||
logger.debug(`removing ${fullPath}`); | ||
fs.unlinkSync(fullPath); | ||
}); | ||
} | ||
}); | ||
}); | ||
} | ||
}); | ||
} | ||
} | ||
} | ||
@@ -49,0 +55,0 @@ |
{ | ||
"name": "ldn-inbox-server", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "A demonstration Event Notifications Inbox server", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
21072
469