Skip to content

Commit 84bc804

Browse files
authored
Merge pull request #2762 from RedisInsight/feature/Ri-5005-autoupdate-checker
Add autoupdate continius checks
2 parents e7b37c9 + 4d61781 commit 84bc804

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

redisinsight/desktop/app.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
/* eslint global-require: off, no-console: off */
22
import { app, nativeTheme } from 'electron'
3+
import log from 'electron-log'
34
import path from 'path'
45
import {
56
initElectronHandlers,
67
initLogging,
78
WindowType,
89
windowFactory,
910
AboutPanelOptions,
10-
checkForUpdate,
11+
initAutoUpdateChecks,
1112
installExtensions,
1213
initTray,
1314
initAutoUpdaterHandlers,
@@ -70,10 +71,12 @@ const init = async () => {
7071

7172
await windowFactory(WindowType.Main, splashWindow, { parsedDeepLink })
7273

73-
checkForUpdate(process.env.MANUAL_UPGRADES_LINK || process.env.UPGRADES_LINK)
74-
} catch (_err) {
75-
const error = _err as Error
76-
console.log(wrapErrorMessageSensitiveData(error))
74+
initAutoUpdateChecks(
75+
process.env.MANUAL_UPGRADES_LINK || process.env.UPGRADES_LINK,
76+
parseInt(process.env.RIAUTOUPDATEINTERVAL, 10) || 84 * 3600 * 1000,
77+
)
78+
} catch (err) {
79+
log.error(wrapErrorMessageSensitiveData(err as Error))
7780
}
7881
}
7982

redisinsight/desktop/src/lib/updater/updater.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,19 @@ export const checkForUpdate = async (url: string = '') => {
3333
autoUpdater.autoDownload = true
3434
autoUpdater.autoInstallOnAppQuit = true
3535

36-
await autoUpdater.checkForUpdates()
36+
const res = await autoUpdater.checkForUpdates()
37+
38+
if (res?.downloadPromise) {
39+
await res.downloadPromise
40+
}
41+
}
42+
43+
export const initAutoUpdateChecks = (url = '', interval = 84 * 3600 * 1000) => {
44+
checkForUpdate(url)
45+
.catch((e) => log.error(wrapErrorMessageSensitiveData(e)))
46+
.finally(() => {
47+
setTimeout(() => initAutoUpdateChecks(url, interval), interval)
48+
})
3749
}
3850

3951
export const quitAndInstallUpdate = () => {

0 commit comments

Comments
 (0)