Merge pull request #176 from atom/unload-on-upgrade
Close all windows before installing update
This commit is contained in:
commit
65f258160e
6 changed files with 31 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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'))
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue