Merge branch 'master' into better-myself-healthcheck

This commit is contained in:
Sam Rose 2024-02-16 16:18:35 +00:00 committed by GitHub
commit 1707fe1e19
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 27 additions and 18 deletions

View File

@ -6,6 +6,7 @@ import * as context from "./context"
import semver from "semver" import semver from "semver"
import { bustCache, withCache, TTL, CacheKey } from "./cache/generic" import { bustCache, withCache, TTL, CacheKey } from "./cache/generic"
import environment from "./environment" import environment from "./environment"
import { logAlert } from "./logging"
export const getInstall = async (): Promise<Installation> => { export const getInstall = async (): Promise<Installation> => {
return withCache(CacheKey.INSTALLATION, TTL.ONE_DAY, getInstallFromDB, { return withCache(CacheKey.INSTALLATION, TTL.ONE_DAY, getInstallFromDB, {
@ -80,6 +81,7 @@ export const checkInstallVersion = async (): Promise<void> => {
const currentVersion = install.version const currentVersion = install.version
const newVersion = environment.VERSION const newVersion = environment.VERSION
try {
if (currentVersion !== newVersion) { if (currentVersion !== newVersion) {
const isUpgrade = semver.gt(newVersion, currentVersion) const isUpgrade = semver.gt(newVersion, currentVersion)
const isDowngrade = semver.lt(newVersion, currentVersion) const isDowngrade = semver.lt(newVersion, currentVersion)
@ -103,4 +105,11 @@ export const checkInstallVersion = async (): Promise<void> => {
await events.identification.identifyInstallationGroup(install.installId) await events.identification.identifyInstallationGroup(install.installId)
} }
} }
} catch (err: any) {
if (err?.message?.includes("Invalid Version")) {
logAlert(`Invalid version "${newVersion}" - is it semver?`)
} else {
logAlert("Failed to retrieve version", err)
}
}
} }