Try to cleanup files only if they stil exist

Fixes #738
This commit is contained in:
Strahinja Val Markovic 2013-12-20 13:01:48 -08:00
parent f286b43404
commit 1edf22357f
2 changed files with 21 additions and 10 deletions

View File

@ -79,6 +79,13 @@ def GetUnusedLocalhostPort():
return port
def RemoveIfExists( filename ):
try:
os.remove( filename )
except OSError:
pass
def Memoize( obj ):
cache = obj.cache = {}

View File

@ -141,10 +141,22 @@ class YouCompleteMe( object ):
return self._server_popen.pid
def _ServerCleanup( self ):
if self._IsServerAlive():
self._server_popen.terminate()
utils.RemoveIfExists( self._temp_options_filename )
if not self._user_options[ 'server_keep_logfiles' ]:
if self._server_stderr:
utils.RemoveIfExists( self._server_stderr )
if self._server_stdout:
utils.RemoveIfExists( self._server_stdout )
def RestartServer( self ):
vimsupport.PostVimMessage( 'Restarting ycmd server...' )
self._user_notified_about_crash = False
self.OnVimLeave()
self._ServerCleanup()
self._SetupServer()
@ -237,15 +249,7 @@ class YouCompleteMe( object ):
def OnVimLeave( self ):
if self._IsServerAlive():
self._server_popen.terminate()
os.remove( self._temp_options_filename )
if not self._user_options[ 'server_keep_logfiles' ]:
if self._server_stderr:
os.remove( self._server_stderr )
if self._server_stdout:
os.remove( self._server_stdout )
self._ServerCleanup()
def OnCurrentIdentifierFinished( self ):