mirror of
https://github.com/atom/atom.git
synced 2026-02-14 08:35:11 -05:00
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:
@@ -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}/"
|
||||
|
||||
Reference in New Issue
Block a user