Westward Electron application automatically updates

Westward Electron application automatically updates

A, Windows Update under specific problem

Software updates, better said, but on Windows you may encounter problems UAC, commonly used method is the Linux and macOS: Windows Scheduled Tasks, compared to Windows Service, or these two methods provide the right Essentially, Windows Service and Windows Scheduled Tasks the greatest feature is the ability to interact with an application, Windows update is to use Windows update services, Microsoft update service even in macOS's Edge browser is used.

Second, the manual update

Manual update is to download the full installation package, users manual installation, if the data needs to be saved locally, not the data stored in the application installation directory, but the user directory.

Suitable highly viscous user manual update, the update application infrequent in the App Store macOS usually just upload installation package, the user terminal can automatically update. Manually update the general will be relatively large installation package, because it is completely downloaded. Generally used as a demotion update program.

Third, update coverage

Automatically replace, download the update process is fast, only need to restart the application, even without rebooting, but prone to write to the file fail, and implement complex, suitable for patching.

Fourth, automatic updates

The application is automatically downloaded, start again after re-load the latest version to the general structure of such an application is to read different versions of the application by the application of a fixed launcher.

Such update speed, and is suitable for application of a high frequency asynchronous update update. The disadvantage is to achieve a certain degree of difficulty.

Five, Electron application update

(1) Web technology

Business Views is stored in the remote HTTPS server, so users perceive no end, but can not cause the application offline, but also compatible with the new framework to achieve a bunch of problems, such as Electron's desktopCapture module.

(2) Automatic Updates official

Squirrel done automatically updated based on the framework and authority to solve the problem.

(3)Updater

Electron official update revision is achieved, provided there are electron-builder.

  • Support for Windows signature verification
  • Support the progress bar
  • Based on electron-builder very easy to use
  • No built-in Windows Update experience is good
  • There is still a problem on Windows permissions

Invoked when you start the update, and then install a button, wait for the update is complete restart.

Sixth, incremental updates

Update only different places, and therefore only the differences to the package, depending on the volume area is determined to modify, common update scheme is as follows:

  • bsdiff, bspatch: very common in the mobile terminal for a binary file, open source, free
  • Xdelta3: suitable for binary
  • Courgette: Google proposed updating scheme, the optimization of bsdiff and bspatch
  • RTPatch: is a commercial program

Seven clients gray release

Control the distribution of risk, based on user label or client features, user experience problems rollback time of publication.

Eight, Electron update server

Electron update server provides several options:

  • Hazel - update servers for private or open source applications can be deployed on free Now. GitHub Releases pull it from the update file fetch, and the use of the strong performance GitHub CDN.
  • Nuts- also uses GitHub Releases, but have to update the application cache and support for private storage library on disk.
  • electron-release-server - provides for processing a dashboard release, and may not require posted on GitHub.
  • Nucleus - a complete update Electron server applications maintained by Atlassian. Support for multiple applications and channels; using a static file server storage to reduce costs.

But the biggest problem is not customized updates, so we can achieve their own update service. In the updated program, the client uses autoUpdater module, but still there are some problems on Windows, such as initial start-up can not be updated, Windows updates are generally static storage, update packages can be stored in the object storage services, such as AWS S3.

autoUpdater is a EventEmitter, offers a range of events, such as thinner is available, the update download is complete, and so on.

Electron update ongoing problem:

  • Documents do not fully covered
  • Bulky package
  • No progress bar

(1) macOS update

Response Contents:

{
  "url": "https://example.com/update/release/name-version-platform.zip",
    "name": "My release name",
    "notes": "Update Text",
    "pub_date": "2020年 4月 1日 星期三 20时23分02秒 CST"
}

Response status code:

  • 204: no content indicates that no update

Test macOS next update:

"Keychain Access" - "Access Certificate" - "Certificate Assistant" - "Create a certificate", select a self-signed certificate. Once created, double-click the certificate installation.

Client code logic:

const {autoUpdater} = require('electron');
autoUpdater.setFeedUrl('https://example.com/update/release/name-version-platform.zip');
autoUpdater.checkForUpdate(); // 检查更新
autoUpdater.quitAndInstall();      // 退出并安装更新

You can monitor events: update-avliable, update-downloaded, error.

Can notify the user via dialog module is updated:

dialog.showMessageBox();   // 显示信息
dialog.showOpenDialog();     // 打开对话框
dialog.showSaveDialog();      // 保存对话框

(2) Windows Update

Response Contents:

包签名 name-version-full.nupkg Hash值

Install the update library:

sudo npm i electron-squirrel-startup --save

When packaged Windows, and creates three files:

  • Installation package
  • Update package
  • RELEASE, the file is updated server response body

Guess you like

Origin blog.51cto.com/xvjunjie/2484067