()
| 101 | } |
| 102 | |
| 103 | export function checkForUpdates() { |
| 104 | if (!app.isPackaged) { |
| 105 | return |
| 106 | } |
| 107 | |
| 108 | autoUpdater.autoDownload = false |
| 109 | autoUpdater.autoInstallOnAppQuit = true |
| 110 | autoUpdater.logger = null |
| 111 | |
| 112 | autoUpdater.on('update-available', (info) => { |
| 113 | const isAutoUpdateEnabled = store.preferences.get('updates.autoUpdate') |
| 114 | const isSameMajor = getMajorVersion(info.version) === currentMajorVersion |
| 115 | |
| 116 | if (!isAutoUpdateEnabled || !isSameMajor) { |
| 117 | notifyAboutUpdate(info.version) |
| 118 | return |
| 119 | } |
| 120 | |
| 121 | autoUpdater.downloadUpdate().catch((error) => { |
| 122 | log('Error downloading update', error) |
| 123 | }) |
| 124 | }) |
| 125 | |
| 126 | autoUpdater.on('update-downloaded', (info) => { |
| 127 | send('system:update-downloaded', { version: info.version }) |
| 128 | }) |
| 129 | |
| 130 | autoUpdater.on('error', (error) => { |
| 131 | log('Auto-update error', error) |
| 132 | }) |
| 133 | |
| 134 | void runUpdateCheck() |
| 135 | |
| 136 | setInterval(() => { |
| 137 | void runUpdateCheck() |
| 138 | }, INTERVAL) |
| 139 | } |
no test coverage detected