fix(db): remove db temp files as well

This commit is contained in:
Evan Morikawa 2015-09-04 14:34:09 -07:00
parent 7126d708ca
commit f8cb9a81eb
2 changed files with 9 additions and 3 deletions

View file

@ -131,6 +131,7 @@ class Application
# exit and then delete the file. It's hard to tell when this happens, so we just
# retry the deletion a few times.
deleteFileWithRetry: (filePath, callback, retries = 5) ->
callback ?= ->
callbackWithRetry = (err) =>
if err and err.message.indexOf('no such file') is -1
console.log("File Error: #{err.message} - retrying in 150msec")
@ -163,13 +164,18 @@ class Application
_logout: =>
@setDatabasePhase('close')
@windowManager.closeAllWindows()
@deleteFileWithRetry path.join(configDirPath,'edgehill.db'), =>
@_deleteDatabase =>
@config.set('tokens', null)
@config.set('nylas', null)
@config.set('edgehill', null)
@setDatabasePhase('setup')
@openWindowsForTokenState()
_deleteDatabase: (callback) ->
@deleteFileWithRetry path.join(configDirPath,'edgehill.db'), callback
@deleteFileWithRetry path.join(configDirPath,'edgehill.db-wal')
@deleteFileWithRetry path.join(configDirPath,'edgehill.db-shm')
_loginSuccessful: =>
@openWindowsForTokenState()
@windowManager.mainWindow().waitForLoad =>
@ -203,7 +209,7 @@ class Application
detail: 'Welcome back to Nylas! We need to rebuild your mailbox to support new features. Please wait a few moments while we re-sync your mail.'
buttons: ['OK']
@deleteFileWithRetry path.join(configDirPath,'edgehill.db'), =>
@_deleteDatabase =>
@setDatabasePhase('setup')
@openWindowsForTokenState()

View file

@ -17,7 +17,7 @@ PriorityUICoordinator = require '../../priority-ui-coordinator'
serializeRegisteredObjects,
deserializeRegisteredObjects} = require '../models/utils'
DatabaseVersion = 13
DatabaseVersion = 14
DatabasePhase =
Setup: 'setup'