From 729a4dc6aeeb00f730feb7b791e153e7cf5a306f Mon Sep 17 00:00:00 2001 From: Zaid Abdulla Date: Sun, 14 May 2017 18:03:48 -0700 Subject: [PATCH] Generate download requests before reboot --- lib/session.coffee | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/session.coffee b/lib/session.coffee index 00997a1..aeab11b 100644 --- a/lib/session.coffee +++ b/lib/session.coffee @@ -987,6 +987,22 @@ generateSetRpcRequest = (sessionContext) -> parameterList: ([p[0].join('.'), p[1], p[2]] for p in parameterValues) } + # Download + iter = syncState.downloadsDownload.entries() + while pair = iter.next().value + if not (pair[1] <= deviceData.attributes.get(pair[0])?.value?[1][0]) + fileTypePath = deviceData.paths.get(pair[0].slice(0, -1).concat('FileType')) + fileNamePath = deviceData.paths.get(pair[0].slice(0, -1).concat('FileName')) + targetFileNamePath = deviceData.paths.get(pair[0].slice(0, -1).concat('TargetFileName')) + return { + name: 'Download' + commandKey: generateRpcId(sessionContext) + instance: pair[0][1] + fileType: deviceData.attributes.get(fileTypePath)?.value?[1][0] + fileName: deviceData.attributes.get(fileNamePath)?.value?[1][0] + targetFileName: deviceData.attributes.get(targetFileNamePath)?.value?[1][0] + } + # Reboot if syncState.reboot? p = sessionContext.deviceData.paths.get(['Reboot']) @@ -1005,22 +1021,6 @@ generateSetRpcRequest = (sessionContext) -> name: 'FactoryReset' } - # Download - iter = syncState.downloadsDownload.entries() - while pair = iter.next().value - if not (pair[1] <= deviceData.attributes.get(pair[0])?.value?[1][0]) - fileTypePath = deviceData.paths.get(pair[0].slice(0, -1).concat('FileType')) - fileNamePath = deviceData.paths.get(pair[0].slice(0, -1).concat('FileName')) - targetFileNamePath = deviceData.paths.get(pair[0].slice(0, -1).concat('TargetFileName')) - return { - name: 'Download' - commandKey: generateRpcId(sessionContext) - instance: pair[0][1] - fileType: deviceData.attributes.get(fileTypePath)?.value?[1][0] - fileName: deviceData.attributes.get(fileNamePath)?.value?[1][0] - targetFileName: deviceData.attributes.get(targetFileNamePath)?.value?[1][0] - } - return null