Added task status code to force saving task. Used in addObject task to avoid data inconsistency and crashing.
This commit is contained in:
1 parent
9537bfad0f
commit
c72705d777
2 files changed
+12
-4
No files matched your search
@@ -180,6 +180,12 @@ runTask = (currentRequest, task, methodResponse) ->
|
||||
res = tr069.response(task._id, cwmpResponse)
|
||||
writeResponse(currentRequest, res)
|
||||
)
|
||||
when tasks.STATUS_SAVE
|
||||
db.saveTask(task, (err) ->
|
||||
throw new Error(err) if err?
|
||||
res = tr069.response(task._id, cwmpResponse)
|
||||
writeResponse(currentRequest, res)
|
||||
)
|
||||
else
|
||||
throw Error('Unknown task status')
|
||||
)
|
||||
|
||||
+6
-4
@@ -7,9 +7,10 @@ BATCH_SIZE = 16
|
||||
|
||||
exports.STATUS_QUEUED = STATUS_QUEUED = 0
|
||||
exports.STATUS_STARTED = STATUS_STARTED = 1
|
||||
exports.STATUS_PENDING = STATUS_PENDING = 2
|
||||
exports.STATUS_FAULT = STATUS_FAULT = 3
|
||||
exports.STATUS_FINISHED = STATUS_FINISHED = 4
|
||||
exports.STATUS_SAVE = STATUS_SAVE = 2
|
||||
exports.STATUS_PENDING = STATUS_PENDING = 3
|
||||
exports.STATUS_FAULT = STATUS_FAULT = 4
|
||||
exports.STATUS_FINISHED = STATUS_FINISHED = 5
|
||||
|
||||
|
||||
initCustomCommands = (deviceId, callback) ->
|
||||
@@ -237,7 +238,8 @@ this.addObject = (task, methodResponse, callback) ->
|
||||
task.parameterNames = []
|
||||
allDeviceUpdates.instanceName = [["#{task.objectName}.#{task.instanceNumber}", task.instanceName]] if task.instanceName?
|
||||
else
|
||||
callback(null, STATUS_STARTED, {methodRequest : {type : 'AddObject', objectName : "#{task.objectName}."}})
|
||||
# Use STATUSS_SAVE to avoid adding object again in case of failure
|
||||
callback(null, STATUS_SAVE, {methodRequest : {type : 'AddObject', objectName : "#{task.objectName}."}})
|
||||
return
|
||||
|
||||
subtask = () =>
|
||||
|
||||
Reference in new issue
Block a user