From 91626a3de52453cd8874c8a772042d01c62ea94c Mon Sep 17 00:00:00 2001 From: Zaid Abdulla Date: Wed, 31 Oct 2018 09:08:50 -0700 Subject: [PATCH] Fix a couple of coffee to js conversion blunders --- lib/db.js | 2 +- lib/soap.js | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/db.js b/lib/db.js index 2c7b5d8..11e455e 100644 --- a/lib/db.js +++ b/lib/db.js @@ -831,7 +831,7 @@ function getDueTasks(deviceId, timestamp, callback) { if (res[0]) { if (!task.fileType) task.fileType = res[0].metadata.fileType; - if (task.fileName) + if (!task.fileName) task.fileName = res[0].filename || res[0]._id.toString(); } diff --git a/lib/soap.js b/lib/soap.js index cef1ce4..2c8b0a6 100644 --- a/lib/soap.js +++ b/lib/soap.js @@ -501,7 +501,7 @@ function faultStruct(xml) { function fault(xml) { let faultCode, faultString, detail; - for (const c of xml.childNodes) { + for (const c of xml.childNodes()) { switch (c.name()) { case "faultcode": faultCode = c.text(); @@ -546,14 +546,16 @@ function request(data, cwmpVersion, warn) { } } - for (const c of headerElement.childNodes()) { - switch (c.name()) { - case "ID": - rpc.id = c.text(); - break; - case "sessionTimeout": - rpc.sessionTimeout = parseInt(c.text()); - break; + if (headerElement) { + for (const c of headerElement.childNodes()) { + switch (c.name()) { + case "ID": + rpc.id = c.text(); + break; + case "sessionTimeout": + rpc.sessionTimeout = parseInt(c.text()); + break; + } } }