Fixed device updates being processed twice potentially impacting performance.

This commit is contained in:
Zaid Abdulla committed 2014-08-20 23:37:07 +03:00
1 parent 7d3618a480
commit 141102908c
1 file changed
+2 -4
+2 -4
View File
@@ -227,9 +227,6 @@ runTask = (currentRequest, task, methodResponse) ->
timeDiff = process.hrtime()
tasks.task(task, methodResponse, (err, status, methodRequest, deviceUpdates) ->
throw err if err
# TODO handle error
updateDevice.queueUpdates(currentRequest.session.deviceId, deviceUpdates, (err) ->
throw err if err
timeDiff = process.hrtime(timeDiff)[0] + 1
if timeDiff > 3 # in seconds
@@ -260,7 +257,9 @@ runTask = (currentRequest, task, methodResponse) ->
)
)
else
updateDevice.queueUpdates(currentRequest.session.deviceId, deviceUpdates, (err) ->
f()
)
when tasks.STATUS_COMPLETED
util.log("#{currentRequest.session.deviceId}: Completed task #{task.name}(#{task._id})")
updateDevice.commitUpdates(currentRequest.session.deviceId, deviceUpdates, true, (err) ->
@@ -287,7 +286,6 @@ runTask = (currentRequest, task, methodResponse) ->
else
throw new Error('Unknown task status')
)
)
isTaskExpired = (task) ->