Improved update processing.

This commit is contained in:
Martin Edenhofer 2013-06-24 17:50:31 +02:00
parent cb6ab39809
commit 4534b3fbba

View file

@ -66,6 +66,7 @@ class _taskManagerSingleton extends App.Controller
super super
@workers = {} @workers = {}
@workersStarted = {} @workersStarted = {}
@taskUpdateProcess = {}
@activeTask = undefined @activeTask = undefined
@tasksInitial() @tasksInitial()
@ -252,19 +253,42 @@ class _taskManagerSingleton extends App.Controller
taskUpdate: (task) -> taskUpdate: (task) ->
@log 'notice', "UPDATE task #{task.id}" @log 'notice', "UPDATE task #{task.id}"
update = -> update = =>
console.log('update', @taskUpdateProcess)
if task.isOnline() if task.isOnline()
task.save() if !@taskUpdateProcess[task.id]
@taskUpdateProcess[task.id] = 0
@taskUpdateProcess[task.id]++
task.save(
success: =>
@taskUpdateProcess[task.id]--
console.log('update done', @taskUpdateProcess)
error: (task) =>
@taskUpdateProcess[task.id]--
console.log('update done', @taskUpdateProcess)
)
App.Event.trigger 'task:render' App.Event.trigger 'task:render'
#update()
@delay( update, 100, task.id, 'taskbar' ) @delay( update, 100, task.id, 'taskbar' )
taskDestroy: (task) -> taskDestroy: (task) ->
@clearDelay( task.id, 'taskbar' ) @clearDelay( task.id, 'taskbar' )
destroy = ->
task.destroy( task.destroy(
success: -> success: ->
App.Event.trigger 'task:render' App.Event.trigger 'task:render'
) )
console.log('delete', @taskUpdateProcess)
# check if update is still in process
if @taskUpdateProcess[task.id]
@delay(
=> @taskDestroy(task)
800
)
return
# destory task in backend
destroy()
tasksInitial: => tasksInitial: =>
# reopen tasks # reopen tasks