Skip to content

Add mechanism for autoUpdater to report a new version without downloading #4587

Closed

Description

@benogle
  • Electron version: 0.36.8
  • Operating system: OSX

Atom has a setting core.automaticallyUpdate, when it's false, we don't check for updates. It would be nice to be able to periodically check if there is an update available, report the version to the user, but without auto-downloading the new update.

This would allow us to provide a mechanism to users to control when they spend that bandwidth, which is a problem for people on data plans. See the manual update section of atom/about#12 (comment) for what this would look like in atom.

Not sure on what the interface could be. Maybe a boolean in checkForUpdates()? Maybe also some data in the update-available event indicating whether or not the update is being downloaded? Just riffing here.

Activity

  1. gschier commented on Jul 27, 2016

    @gschier

    This is something that I'd also like to see.

    As a workaround, I am thinking of hosting my own endpoint to call to see if there is an update available then, if there is, prompt the user to download/install it which would call autoUpdater.checkForUpdates().

  2. BrandonSmith commented on Jul 27, 2016

    @BrandonSmith

    @gschier My app implements a preCheckForUpdates function using the same strategy you describe.

  3. itpimp commented on Aug 17, 2017

    @itpimp

    My workaround solution [not pretty, but works like a bomb]:
    I have main.js, index.html (loading / splash window) and updater.html.

    index.html queries the RELEASES file to determine if there is an update:

    request({url		: protocol+url+'/xxxxxx/win/' + (os.arch() === 'x64' ? '64' : '32')+'/RELEASES'},
    	function(err, response, body) {
    		if(err){console.log('continue')
    			ipcRenderer.send('error', 'Could not retrieve update listing.');
    		}
    		lines = body.split('\n')
    		sVersion = lines[lines.length-1].split(' ')[1].split('-')[1].split('.')
    		sSize = (lines[lines.length-1].split(' ')[2] / 1024 / 1024)
    		lVersion = package.version.split('.')
    		newer = false
    		if(!newer && sVersion[0] > lVersion[0]) newer = true;
    		if(!newer && sVersion[1] > lVersion[1]) newer = true;
    		if(!newer && sVersion[2] > lVersion[2]) newer = true;
    		if(newer){
    			if(confirm("A newer version of "+package.name+" is available.\n\nNew version\t: "+lines[lines.length-1].split(' ')[1].split('-')[1]+"\nSize\t\t\t: "+numeral(sSize).format('0,0')+"MB\n\nWould you like install it?")){
    				ipcRenderer.send('go4update', '');
    			}else{console.log('continue')}
    		}else{console.log('continue')}
    	}
    );
    

    And then in main.js:

    ipcMain.on('go4update', (event, arg) => {
    	updtWindow						= new BrowserWindow(
    		{
    			alwaysOnTop				: true,
    			title						: 'Updating ...',
    			width					: 280,
    			height					: 265,
    			frame					: false,
    			autoHideMenuBar			: true,
    			resizable					: false
    		}
    	)
    	loadWindow.close();
    	loadWindow						= null
    	updtWindow.loadURL(url.format({
    		pathname					: path.join(__dirname, 'updater.html'),
    		protocol						: 'file:',
    		slashes						: true
    	}))
    })
    

    And then updater.html (with goForUpdate() onload):

    	var feedURL;
    	const remote						= require("electron").remote
    	const electron						= remote.electron
    	const app						= remote.app
    	const autoUpdater					= remote.autoUpdater
    	const os							= require('os');
    	const {ipcRenderer}					= require('electron')
    	const package						= require('./package.json')
    	const environ						= require('./package.json').applicationParameters.development
    	const tcpp						= require('tcp-ping')
    	const request						= require('request');
    	var numeral						= require('numeral');
    
    	function goForUpdate(){
    	  autoUpdater.on('update-downloaded', (e) => {
    			autoUpdater.quitAndInstall()
    	  })
    		feedURL						= environ.website.protocol+environ.website.url+'/xxxxxx/win/' + (os.arch() === 'x64' ? '64' : '32')
    		autoUpdater.setFeedURL(feedURL)
    		try{
    			autoUpdater.checkForUpdates()
    		  window.autoUpdater = autoUpdater
    		}catch(e){}
    	}
    
  4. codebytere commented on Feb 10, 2019

    @codebytere
    Member

    Given that this issue has been open in stasis for years, that a workaround exists, and that this isn't currently on our roadmap, i'm going to go ahead and label this a wontfix. However, should someone determine a workable solution we would be very open to accepting a PR!

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions