Don't delete InternetGatewayDevice tree when reinitializing device
This commit is contained in:
1 parent
8167c0c6e5
commit
bcfd56d868
2 files changed
+5
-3
No files matched your search
@@ -117,12 +117,10 @@ updateDevice = (currentRequest, actions, callback) ->
|
|||||||
)
|
)
|
||||||
else if updates['_lastBootstrap']?
|
else if updates['_lastBootstrap']?
|
||||||
# reinitialize on bootstrap event (e.g. firmware upgrade)
|
# reinitialize on bootstrap event (e.g. firmware upgrade)
|
||||||
db.devicesCollection.update({'_id' : currentRequest.deviceId}, {'$unset' : 'InternetGatewayDevice'}, {safe: true}, (err, count) ->
|
|
||||||
task = {device : currentRequest.deviceId, name : 'init', timestamp : config.INIT_TIMESTAMP}
|
task = {device : currentRequest.deviceId, name : 'init', timestamp : config.INIT_TIMESTAMP}
|
||||||
apiFunctions.insertTasks(task, (err) ->
|
apiFunctions.insertTasks(task, (err) ->
|
||||||
callback(err) if callback?
|
callback(err) if callback?
|
||||||
)
|
)
|
||||||
)
|
|
||||||
else
|
else
|
||||||
callback() if callback?
|
callback() if callback?
|
||||||
)
|
)
|
||||||
|
|||||||
+5
-1
@@ -108,11 +108,12 @@ this.getParameterNames = (task, methodResponse, callback) ->
|
|||||||
deviceUpdates = {parameterNames : methodResponse.parameterList}
|
deviceUpdates = {parameterNames : methodResponse.parameterList}
|
||||||
path = if common.endsWith(task.parameterPath, '.') then task.parameterPath.slice(0, -1) else task.parameterPath
|
path = if common.endsWith(task.parameterPath, '.') then task.parameterPath.slice(0, -1) else task.parameterPath
|
||||||
projection = {}
|
projection = {}
|
||||||
projection[path] = 1
|
projection[path] = 1 if !!task.parameterPath
|
||||||
|
|
||||||
# delete nonexisting params
|
# delete nonexisting params
|
||||||
db.devicesCollection.findOne({_id : task.device}, projection, (err, device) ->
|
db.devicesCollection.findOne({_id : task.device}, projection, (err, device) ->
|
||||||
if device
|
if device
|
||||||
|
if !!task.parameterPath
|
||||||
root = device
|
root = device
|
||||||
rootPath = ''
|
rootPath = ''
|
||||||
ps = path.split('.')
|
ps = path.split('.')
|
||||||
@@ -123,6 +124,9 @@ this.getParameterNames = (task, methodResponse, callback) ->
|
|||||||
else
|
else
|
||||||
root = null
|
root = null
|
||||||
break
|
break
|
||||||
|
else
|
||||||
|
root = device['InternetGatewayDevice']
|
||||||
|
rootPath = 'InternetGatewayDevice.'
|
||||||
|
|
||||||
if root
|
if root
|
||||||
deviceUpdates.deletedObjects = []
|
deviceUpdates.deletedObjects = []
|
||||||
|
|||||||
Reference in new issue
Block a user