mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-06 20:54:26 +08:00
fix(windows): Minor changes to support windows
Summary: Small tweaks to fix the windows build. Details in inline comments Test Plan: Run windows build Reviewers: evan Reviewed By: evan Differential Revision: https://phab.nylas.com/D1689
This commit is contained in:
parent
00d6a11512
commit
2499e7b57b
7 changed files with 36 additions and 24 deletions
|
@ -77,12 +77,14 @@ class Application
|
|||
@config = new Config({configDirPath, @resourcePath})
|
||||
@config.load()
|
||||
|
||||
@databaseManager = new DatabaseManager({@resourcePath})
|
||||
@windowManager = new WindowManager({@resourcePath, @config, @devMode, @safeMode})
|
||||
@autoUpdateManager = new AutoUpdateManager(@version, @config, @specMode)
|
||||
@applicationMenu = new ApplicationMenu(@version)
|
||||
@nylasProtocolHandler = new NylasProtocolHandler(@resourcePath, @safeMode)
|
||||
|
||||
@databaseManager = new DatabaseManager({@resourcePath})
|
||||
@databaseManager.on "setup-error", @_logout
|
||||
|
||||
@listenForArgumentsFromNewProcess()
|
||||
@setupJavaScriptArguments()
|
||||
@handleEvents()
|
||||
|
@ -129,6 +131,7 @@ class Application
|
|||
app.commandLine.appendSwitch 'js-flags', '--harmony'
|
||||
|
||||
_logout: =>
|
||||
@databaseManager.deleteAllDatabases()
|
||||
@config.set('nylas', null)
|
||||
@config.set('edgehill', null)
|
||||
|
||||
|
@ -283,8 +286,6 @@ class Application
|
|||
# executes them, and returns the responses to the remote renderer processes
|
||||
ipc.on 'database-query', @databaseManager.onIPCDatabaseQuery
|
||||
|
||||
@databaseManager.on "setup-error", @_logout
|
||||
|
||||
# Public: Executes the given command.
|
||||
#
|
||||
# If it isn't handled globally, delegate to the currently focused window.
|
||||
|
|
|
@ -58,7 +58,7 @@ class DatabaseManager
|
|||
@_setupQueries ?= {}
|
||||
@_setupQueries[databasePath] = setupQueries
|
||||
|
||||
_closeDatabaseConnection: (databasePath) ->
|
||||
closeDatabaseConnection: (databasePath) ->
|
||||
@_databases[databasePath]?.close()
|
||||
delete @_databases[databasePath]
|
||||
|
||||
|
@ -66,6 +66,13 @@ class DatabaseManager
|
|||
for path, val of @_databases
|
||||
@_closeDatabaseConnection(path)
|
||||
|
||||
deleteAllDatabases: ->
|
||||
Object.keys(@_databases).forEach (path) =>
|
||||
db = @_databases[path]
|
||||
db.on 'close', -> fs.unlinkSync(path)
|
||||
db.close()
|
||||
delete @_databases[path]
|
||||
|
||||
onIPCDatabaseQuery: (event, {databasePath, queryKey, query, values}) =>
|
||||
db = @_databases[databasePath]
|
||||
|
||||
|
@ -113,8 +120,7 @@ class DatabaseManager
|
|||
setupPromise.then ->
|
||||
return Promise.resolve(db)
|
||||
.catch (err) ->
|
||||
@emit "setup-error", err
|
||||
@_deleteAllDatabases()
|
||||
@emit("setup-error", err)
|
||||
console.error "There was an error setting up the database #{err?.message}"
|
||||
return Promise.reject(err)
|
||||
|
||||
|
@ -136,9 +142,4 @@ class DatabaseManager
|
|||
dblite.bin = "#{vendor}/sqlite3-darwin"
|
||||
resolve(dblite)
|
||||
|
||||
_deleteAllDatabases: ->
|
||||
for path, val of @_databases
|
||||
@closeDatabaseConnection(path)
|
||||
fs.unlinkSync(path)
|
||||
|
||||
module.exports = DatabaseManager
|
||||
|
|
|
@ -10,6 +10,8 @@ start = ->
|
|||
|
||||
global.errorReporter = setupErrorReporter(args)
|
||||
|
||||
setupCoffeeScript()
|
||||
|
||||
if process.platform is 'win32'
|
||||
SquirrelUpdate = require './squirrel-update'
|
||||
squirrelCommand = process.argv[1]
|
||||
|
@ -41,8 +43,6 @@ start = ->
|
|||
else
|
||||
path.resolve(pathToOpen.toString())
|
||||
|
||||
setupCoffeeScript()
|
||||
|
||||
if args.devMode
|
||||
require(path.join(args.resourcePath, 'src', 'coffee-cache')).register()
|
||||
Application = require path.join(args.resourcePath, 'src', 'browser', 'application')
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
var SquirrelUpdate, addPathToOpen, addUrlToOpen, args, squirrelCommand;
|
||||
args = parseCommandLine();
|
||||
global.errorReporter = setupErrorReporter(args);
|
||||
setupCoffeeScript();
|
||||
if (process.platform === 'win32') {
|
||||
SquirrelUpdate = require('./squirrel-update');
|
||||
squirrelCommand = process.argv[1];
|
||||
|
@ -46,7 +47,6 @@
|
|||
return path.resolve(pathToOpen.toString());
|
||||
}
|
||||
});
|
||||
setupCoffeeScript();
|
||||
if (args.devMode) {
|
||||
require(path.join(args.resourcePath, 'src', 'coffee-cache')).register();
|
||||
Application = require(path.join(args.resourcePath, 'src', 'browser', 'application'));
|
||||
|
|
|
@ -404,10 +404,18 @@ class WindowManager
|
|||
window.browserWindow.removeListener('focus', focusHandler)
|
||||
|
||||
windowClosedOrHidden: ->
|
||||
# On Windows and Linux, we want to terminate the app after the last visible
|
||||
# window is closed. However, there are brief moments where the app has no
|
||||
# windows, like when you log out or finish logging in. Wait a while after
|
||||
# the last window close event to see if we should quit.
|
||||
if process.platform in ['win32', 'linux']
|
||||
if @visibleWindows().length is 0
|
||||
# Quitting the app from within a window event handler causes
|
||||
# an assertion error. Wait a moment.
|
||||
_.defer -> app.quit()
|
||||
@quitCheck ?= _.debounce =>
|
||||
noVisibleWindows = @visibleWindows().length is 0
|
||||
mainWindowLoading = @mainWindow and not @mainWindow.loaded
|
||||
if noVisibleWindows and not mainWindowLoading
|
||||
app.quit()
|
||||
, 10000
|
||||
@quitCheck()
|
||||
|
||||
|
||||
module.exports = WindowManager
|
||||
|
|
|
@ -177,7 +177,11 @@ Utils =
|
|||
files = fs.listTreeSync(imagesPath)
|
||||
|
||||
Utils.images[resourcePath] ?= {}
|
||||
Utils.images[resourcePath][path.basename(file)] = file for file in files
|
||||
for file in files
|
||||
# On Windows, we get paths like C:\images\compose.png, but Chromium doesn't
|
||||
# accept the backward slashes. Convert to C:/images/compose.png
|
||||
file = file.replace(/\\/g, '/')
|
||||
Utils.images[resourcePath][path.basename(file)] = file
|
||||
|
||||
if window.devicePixelRatio > 1
|
||||
return Utils.images[resourcePath]["#{name}@2x.#{ext}"] ? Utils.images[resourcePath][fullname] ? Utils.images[resourcePath]["#{name}@1x.#{ext}"]
|
||||
|
|
8
vendor/dblite-custom.js
vendored
8
vendor/dblite-custom.js
vendored
|
@ -239,11 +239,8 @@ function dblite() {
|
|||
// when program is killed or closed for some reason
|
||||
// the dblite object needs to be notified too
|
||||
function close(code) {
|
||||
if (self.listeners('close').length) {
|
||||
self.emit('close', code);
|
||||
} else {
|
||||
log('bye bye');
|
||||
}
|
||||
self.emit('close', code);
|
||||
log('bye bye');
|
||||
}
|
||||
|
||||
// as long as there's something else to do ...
|
||||
|
@ -422,6 +419,7 @@ function dblite() {
|
|||
if (!closeRequested) {
|
||||
var kill = function() {
|
||||
closed = true;
|
||||
close(); // other function defined above
|
||||
program.stdin.end();
|
||||
program.kill();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue