()
| 40 | } |
| 41 | |
| 42 | function checkForUpdatesAndNotify() { |
| 43 | if (!autoUpdater.isUpdaterActive()) { |
| 44 | return Promise.resolve(null) |
| 45 | } |
| 46 | return autoUpdater |
| 47 | .checkForUpdates() |
| 48 | .then((it) => { |
| 49 | lastSuccessfulCheckTime = Date.now() |
| 50 | if (!it) { |
| 51 | return |
| 52 | } |
| 53 | const downloadPromise = it.downloadPromise |
| 54 | if (downloadPromise == null) { |
| 55 | // @ts-ignore |
| 56 | const debug = autoUpdater._logger.debug |
| 57 | if (debug != null) { |
| 58 | debug("checkForUpdatesAndNotify called, downloadPromise is null") |
| 59 | } |
| 60 | return it |
| 61 | } |
| 62 | downloadPromise |
| 63 | .then(() => { |
| 64 | notifyFeOnUpdateAvailable() |
| 65 | }) |
| 66 | .catch((e: unknown) => { |
| 67 | logger.warn("Auto-update download failed", e) |
| 68 | notifyFeOnUpdateError() |
| 69 | }) |
| 70 | return it |
| 71 | }) |
| 72 | .catch((e: unknown) => { |
| 73 | logger.warn("Auto-update check failed", e) |
| 74 | if (Date.now() - lastSuccessfulCheckTime > STALE_UPDATE_THRESHOLD_MS) { |
| 75 | notifyFeOnUpdateError() |
| 76 | } |
| 77 | return null |
| 78 | }) |
| 79 | } |
| 80 | |
| 81 | export const load = () => { |
| 82 | // Check for updates |
no test coverage detected