Don't delete InternetGatewayDevice tree when reinitializing device

This commit is contained in:
Zaid Abdulla committed 2013-07-22 20:32:32 +03:00
1 parent 8167c0c6e5
commit bcfd56d868
2 files changed
+5 -3

No files matched your search

-2
View File
@@ -117,12 +117,10 @@ updateDevice = (currentRequest, actions, callback) ->
)
else if updates['_lastBootstrap']?
# 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}
apiFunctions.insertTasks(task, (err) ->
callback(err) if callback?
)
)
else
callback() if callback?
)
+5 -1
View File
@@ -108,11 +108,12 @@ this.getParameterNames = (task, methodResponse, callback) ->
deviceUpdates = {parameterNames : methodResponse.parameterList}
path = if common.endsWith(task.parameterPath, '.') then task.parameterPath.slice(0, -1) else task.parameterPath
projection = {}
projection[path] = 1
projection[path] = 1 if !!task.parameterPath
# delete nonexisting params
db.devicesCollection.findOne({_id : task.device}, projection, (err, device) ->
if device
if !!task.parameterPath
root = device
rootPath = ''
ps = path.split('.')
@@ -123,6 +124,9 @@ this.getParameterNames = (task, methodResponse, callback) ->
else
root = null
break
else
root = device['InternetGatewayDevice']
rootPath = 'InternetGatewayDevice.'
if root
deviceUpdates.deletedObjects = []