Use a single worker for status refreshes

There still appear to be crashes occurring when
using libgit2 from multiple workers at the same time.

So only start a new status worker once the current one
completes if a refresh was requested while a worker was
running.

Closes #367
This commit is contained in:
Kevin Sawicki
2013-03-06 14:59:12 -08:00
parent b76ab87a96
commit 8af55a04d8
3 changed files with 42 additions and 3 deletions

View File

@@ -28,6 +28,7 @@ class Git
statuses: null
upstream: null
statusTask: null
constructor: (path, options={}) ->
@statuses = {}
@@ -58,7 +59,11 @@ class Git
@path ?= fs.absolute(@getRepo().getPath())
destroy: ->
@statusTask?.abort()
if @statusTask?
@statusTask.abort()
@statusTask.off()
@statusTask = null
@getRepo().destroy()
@repo = null
@unsubscribe()
@@ -130,8 +135,16 @@ class Git
@getRepo().isSubmodule(@relativize(path))
refreshStatus: ->
@statusTask = new RepositoryStatusTask(this)
@statusTask.start()
if @statusTask?
@statusTask.off()
@statusTask.one 'task-completed', =>
@statusTask = null
@refreshStatus()
else
@statusTask = new RepositoryStatusTask(this)
@statusTask.one 'task-completed', =>
@statusTask = null
@statusTask.start()
getDirectoryStatus: (directoryPath) ->
directoryPath = "#{directoryPath}/"