Merge pull request #176 from atom/unload-on-upgrade

Close all windows before installing update
This commit is contained in:
Cheng Zhao 2014-02-17 18:14:14 +08:00
commit 65f258160e
6 changed files with 31 additions and 6 deletions

View file

@ -80,7 +80,9 @@ void AutoUpdater::CheckForUpdates(
void AutoUpdater::QuitAndInstall(
const v8::FunctionCallbackInfo<v8::Value>& args) {
AutoUpdater* self = AutoUpdater::Unwrap<AutoUpdater>(args.This());
self->quit_and_install_.Run();
if (!self->quit_and_install_.is_null())
self->quit_and_install_.Run();
}
// static

View file

@ -8,4 +8,18 @@ autoUpdater.on 'update-downloaded-raw', (args...) ->
args[3] = new Date(args[3]) # releaseDate
@emit 'update-downloaded', args..., => @quitAndInstall()
autoUpdater.quitAndInstall = ->
# If we don't have any window then quitAndInstall immediately.
BrowserWindow = require 'browser-window'
windows = BrowserWindow.getAllWindows()
if windows.length is 0
AutoUpdater::quitAndInstall.call this
return
# Do the restart after all windows have been closed.
app = require 'app'
app.removeAllListeners 'window-all-closed'
app.once 'window-all-closed', AutoUpdater::quitAndInstall.bind(this)
win.close() for win in windows
module.exports = autoUpdater

View file

@ -5,6 +5,7 @@ sendWrap = (channel, processId, routingId, args...) ->
BrowserWindow = require 'browser-window'
if processId?.constructor is BrowserWindow
window = processId
args = [routingId, args...]
processId = window.getProcessId()
routingId = window.getRoutingId()

View file

@ -56,7 +56,7 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
class DialogScope {
public:
DialogScope(NativeWindow* window)
explicit DialogScope(NativeWindow* window)
: window_(window) {
if (window_ != NULL)
window_->set_has_dialog_attached(true);

View file

@ -11,6 +11,8 @@ SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
def main():
os.environ['CI'] = '1'
rm_rf(os.path.join(SOURCE_ROOT, 'out'))
rm_rf(os.path.join(SOURCE_ROOT, 'node_modules'))
rm_rf(os.path.join(SOURCE_ROOT, 'frameworks'))

View file

@ -36,6 +36,8 @@ def download(text, url, path):
downloaded_size = 0
block_size = 128
ci = os.environ.get('CI') == '1'
while True:
buf = web_file.read(block_size)
if not buf:
@ -44,11 +46,15 @@ def download(text, url, path):
downloaded_size += len(buf)
local_file.write(buf)
percent = downloaded_size * 100. / file_size
status = "\r%s %10d [%3.1f%%]" % (text, downloaded_size, percent)
print status,
if not ci:
percent = downloaded_size * 100. / file_size
status = "\r%s %10d [%3.1f%%]" % (text, downloaded_size, percent)
print status,
print
if ci:
print "%s done." % (text)
else:
print
def extract_tarball(tarball_path, member, destination):