From a8b5bb243f07f8ac33f4e13a9487f48e52ec5b63 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Mon, 2 Nov 2015 10:46:11 +0100 Subject: [PATCH] Save BlobStore only in the first window --- src/browser/atom-application.coffee | 4 ++++ src/browser/atom-window.coffee | 3 +++ static/index.js | 4 ++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/browser/atom-application.coffee b/src/browser/atom-application.coffee index b68ee2c73..299dc2adb 100644 --- a/src/browser/atom-application.coffee +++ b/src/browser/atom-application.coffee @@ -212,6 +212,7 @@ class AtomApplication @openPathOnEvent('application:open-license', path.join(process.resourcesPath, 'LICENSE.md')) app.on 'before-quit', => + @saveBlobStore() @saveState(false) @quitting = true @@ -433,6 +434,9 @@ class AtomApplication console.log("Killing process #{pid} failed: #{error.code ? error.message}") delete @pidsToOpenWindows[pid] + saveBlobStore: -> + @windows[0]?.saveBlobStore() + saveState: (allowEmpty=false) -> return if @quitting states = [] diff --git a/src/browser/atom-window.coffee b/src/browser/atom-window.coffee index 16456d274..73b8a05b8 100644 --- a/src/browser/atom-window.coffee +++ b/src/browser/atom-window.coffee @@ -75,6 +75,9 @@ class AtomWindow hasPathToOpen = not (locationsToOpen.length is 1 and not locationsToOpen[0].pathToOpen?) @openLocations(locationsToOpen) if hasPathToOpen and not @isSpecWindow() + saveBlobStore: -> + @browserWindow.webContents?.send('save-blob-store') + setLoadSettings: (loadSettingsObj) -> # Ignore the windowState when passing loadSettings via URL, since it could # be quite large. diff --git a/static/index.js b/static/index.js index 3e02b6497..f0b424e6c 100644 --- a/static/index.js +++ b/static/index.js @@ -1,15 +1,15 @@ (function () { - var app = require('remote').require('app') var fs = require('fs-plus') var path = require('path') var FileSystemBlobStore = require('../src/file-system-blob-store') var NativeCompileCache = require('../src/native-compile-cache') + var ipc = require('ipc') var loadSettings = null var loadSettingsError = null var blobStore = null - app.on('before-quit', function () { + ipc.on('save-blob-store', function () { if (blobStore) { blobStore.save() }