Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NSIS AutoUpdater QuitAndInstall prompting user to close app before installing #1368

Closed
dustintownsend opened this issue Mar 14, 2017 · 5 comments · May be fixed by qcif/data-curator#563
Closed

Comments

@dustintownsend
Copy link

  • Builder Version: 15.2.0
  • Updater Version: 1.8.2
  • Target: NSIS / Win

After an update is downloaded I call quitAndInstall. It works, but the installer opens before it is able to fully close the application.
The message is APPNAME is running. Click OK to close it and continue with install.
If you click okay it runs the installer and relaunched with no issues.

Is there anyway to prevent this prompt and just default to close the application and continue with the install?

@ghost
Copy link

ghost commented Mar 14, 2017

you have manage to manualy update the app??? not auto

@ghost
Copy link

ghost commented Mar 14, 2017

like if update is avalable and if user want to instal now or later

@dustintownsend
Copy link
Author

@George35mk the check for update is done before a "sync" action happens. I want to make sure the user is running the latest version before the sync happens. This happens in the background as this app runs in the users app tray.

@ghost
Copy link

ghost commented Mar 14, 2017

dustintownsend look my main.js

i think is gona help you if yes tell me i want to ask you to help me to maybe you know

################################################################

`console.time('init');

const {app, BrowserWindow, Menu, protocol, ipcMain} = require('electron');
const log = require('electron-log');
const {autoUpdater} = require("electron-updater");

//-------------------------------------------------------------------
// Logging
//
// THIS SECTION IS NOT REQUIRED
//
// This logging setup is not required for auto-updates to work,
// but it sure makes debugging easier :)
//-------------------------------------------------------------------
autoUpdater.logger = log;
autoUpdater.logger.transports.file.level = 'info';
log.info('App starting...');

//-------------------------------------------------------------------
// Open a window that displays the version
//
// THIS SECTION IS NOT REQUIRED
//
// This isn't required for auto-updates to work, but it's easier
// for the app to show a window than to have to click "About" to see
// that updates are working.
//-------------------------------------------------------------------
let win;

function sendStatusToWindow(text) {
log.info(text);
win.webContents.send('message', text);
}

function createDefaultWindow() {
win = new BrowserWindow({
width:800,
height: 600,
minWidth: 600,
minHeight: 400,
// 'auto-hide-menu-bar': true,
center: true
});
win.webContents.openDevTools();
win.on('closed', () => {
win = null;
});
win.loadURL(file://${__dirname}/index.html#v${app.getVersion()});
console.log(app.getVersion());
// win.loadURL(file://${__dirname}/index.html);
// win.webContents.openDevTools();
return win;
}

autoUpdater.on('checking-for-update', () => {
sendStatusToWindow('Checking for update...');
})
autoUpdater.on('update-available', (ev, info) => {
sendStatusToWindow('Update available.');
})
autoUpdater.on('update-not-available', (ev, info) => {
sendStatusToWindow('Update not available.');
})
autoUpdater.on('error', (ev, err) => {
sendStatusToWindow('Error in auto-updater.');
})
autoUpdater.on('download-progress', (ev, progressObj) => {
sendStatusToWindow('Download progress...');
})
autoUpdater.on('update-downloaded', (ev, info) => {
sendStatusToWindow('Update downloaded; will install in 5 seconds');
});

app.on('ready', function() {
// Create the Menu
// const menu = Menu.buildFromTemplate(template);
// Menu.setApplicationMenu(menu);

createDefaultWindow();
});
app.on('window-all-closed', () => {
app.quit();
});

//-------------------------------------------------------------------
// Auto updates
//
// For details about these events, see the Wiki:
// https://github.com/electron-userland/electron-builder/wiki/Auto-Update#events
//
// The app doesn't need to listen to any events except update-downloaded
//
// Uncomment any of the below events to listen for them. Also,
// look in the previous section to see them being used.
//-------------------------------------------------------------------
// autoUpdater.on('checking-for-update', () => {
// })
// autoUpdater.on('update-available', (ev, info) => {
// })
// autoUpdater.on('update-not-available', (ev, info) => {
// })
// autoUpdater.on('error', (ev, err) => {
// })
// autoUpdater.on('download-progress', (ev, progressObj) => {
// })

autoUpdater.on('update-downloaded', (ev, info) => {
// Wait 5 seconds, then quit and install
// In your application, you don't need to wait 5 seconds.
// You could call autoUpdater.quitAndInstall(); immediately

setTimeout(function() {
// autoUpdater.quitAndInstall();
}, 5000)
})

app.on('ready', function() {
autoUpdater.checkForUpdates();
});

console.timeEnd('init');`

@ghost
Copy link

ghost commented Mar 14, 2017

is work ???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants