🚱 Destroy repo in Project::setPath

Previously if the new path was non-null then the current repo would be
leaked and never destroyed
This commit is contained in:
Kevin Sawicki 2013-08-29 18:05:18 -07:00
parent 9f1edd3189
commit 989fffba6a

View File

@ -54,6 +54,10 @@ class Project
destroy: ->
editSession.destroy() for editSession in @getEditSessions()
buffer.release() for buffer in @getBuffers()
@destroyRepo()
# Private:
destroyRepo: ->
if @repo?
@repo.destroy()
@repo = null
@ -113,15 +117,13 @@ class Project
setPath: (projectPath) ->
@rootDirectory?.off()
@destroyRepo()
if projectPath?
directory = if fsUtils.isDirectorySync(projectPath) then projectPath else path.dirname(projectPath)
@rootDirectory = new Directory(directory)
@repo = Git.open(projectPath)
else
@rootDirectory = null
if @repo?
@repo.destroy()
@repo = null
if originUrl = @repo?.getOriginUrl()
@state.set('repoUrl', originUrl)