mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 15:37:46 +03:00
🚱 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:
parent
9f1edd3189
commit
989fffba6a
@ -54,6 +54,10 @@ class Project
|
|||||||
destroy: ->
|
destroy: ->
|
||||||
editSession.destroy() for editSession in @getEditSessions()
|
editSession.destroy() for editSession in @getEditSessions()
|
||||||
buffer.release() for buffer in @getBuffers()
|
buffer.release() for buffer in @getBuffers()
|
||||||
|
@destroyRepo()
|
||||||
|
|
||||||
|
# Private:
|
||||||
|
destroyRepo: ->
|
||||||
if @repo?
|
if @repo?
|
||||||
@repo.destroy()
|
@repo.destroy()
|
||||||
@repo = null
|
@repo = null
|
||||||
@ -113,15 +117,13 @@ class Project
|
|||||||
setPath: (projectPath) ->
|
setPath: (projectPath) ->
|
||||||
@rootDirectory?.off()
|
@rootDirectory?.off()
|
||||||
|
|
||||||
|
@destroyRepo()
|
||||||
if projectPath?
|
if projectPath?
|
||||||
directory = if fsUtils.isDirectorySync(projectPath) then projectPath else path.dirname(projectPath)
|
directory = if fsUtils.isDirectorySync(projectPath) then projectPath else path.dirname(projectPath)
|
||||||
@rootDirectory = new Directory(directory)
|
@rootDirectory = new Directory(directory)
|
||||||
@repo = Git.open(projectPath)
|
@repo = Git.open(projectPath)
|
||||||
else
|
else
|
||||||
@rootDirectory = null
|
@rootDirectory = null
|
||||||
if @repo?
|
|
||||||
@repo.destroy()
|
|
||||||
@repo = null
|
|
||||||
|
|
||||||
if originUrl = @repo?.getOriginUrl()
|
if originUrl = @repo?.getOriginUrl()
|
||||||
@state.set('repoUrl', originUrl)
|
@state.set('repoUrl', originUrl)
|
||||||
|
Loading…
Reference in New Issue
Block a user