check for newer updates (#784)
Co-authored-by: Jeffrey Morgan <jmorganca@gmail.com>
This commit is contained in:
parent
6fe178134d
commit
3553d10769
|
@ -162,13 +162,43 @@ app.on('before-quit', () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
function init() {
|
let currentReleaseURL = ''
|
||||||
if (app.isPackaged) {
|
|
||||||
autoUpdater.checkForUpdates()
|
async function isNewReleaseAvailable() {
|
||||||
setInterval(() => {
|
try {
|
||||||
if (!updateAvailable) {
|
const response = await fetch('https://ollama.ai/api/update')
|
||||||
|
|
||||||
|
if (response.status === 204) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await response.json()
|
||||||
|
|
||||||
|
if (currentReleaseURL === data.url) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
currentReleaseURL = data.url
|
||||||
|
return true
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(`update check failed - ${error}`)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function checkUpdate() {
|
||||||
|
const available = await isNewReleaseAvailable()
|
||||||
|
if (available) {
|
||||||
|
logger.info('checking for update')
|
||||||
autoUpdater.checkForUpdates()
|
autoUpdater.checkForUpdates()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
if (app.isPackaged) {
|
||||||
|
checkUpdate()
|
||||||
|
setInterval(() => {
|
||||||
|
checkUpdate()
|
||||||
}, 60 * 60 * 1000)
|
}, 60 * 60 * 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue