Improved update processing.
This commit is contained in:
parent
cb6ab39809
commit
4534b3fbba
1 changed files with 33 additions and 9 deletions
|
@ -64,8 +64,9 @@ class _taskManagerSingleton extends App.Controller
|
||||||
|
|
||||||
constructor: ->
|
constructor: ->
|
||||||
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' )
|
||||||
task.destroy(
|
destroy = ->
|
||||||
success: ->
|
task.destroy(
|
||||||
App.Event.trigger 'task:render'
|
success: ->
|
||||||
)
|
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
|
||||||
|
|
Loading…
Reference in a new issue