v1.0.58: add logging around the update-check so silent failures are visible
This commit is contained in:
+19
-5
@@ -1,4 +1,4 @@
|
||||
const CURRENT_VERSION = "1.0.57";
|
||||
const CURRENT_VERSION = "1.0.58";
|
||||
const GITEA_BASE = "https://gitea.pdmarf.co.uk/pdm/stream_deck_notion_timer/raw/branch/stable-rebuild";
|
||||
const SIGNING_PUBLIC_KEY = `-----BEGIN PUBLIC KEY-----
|
||||
MCowBQYDK2VwAyEAN7ko8TUpuPzPAJuKAZCRjV0c4ZSlou5d9pUAF6o12b4=
|
||||
@@ -22,10 +22,18 @@ function fetchWithTimeout(url: string): Promise<Response> {
|
||||
async function checkForUpdates(sendStatus?: (msg: string) => void | Promise<void>): Promise<void> {
|
||||
try {
|
||||
const resp = await fetchWithTimeout(`${GITEA_BASE}/version.json`);
|
||||
if (!resp.ok) { sendStatus?.("Update check failed"); return; }
|
||||
if (!resp.ok) {
|
||||
streamDeck.logger.warn(`Update check: version.json fetch returned ${resp.status}`);
|
||||
sendStatus?.("Update check failed");
|
||||
return;
|
||||
}
|
||||
const { version } = await resp.json() as { version: string };
|
||||
if (!/^\d+\.\d+\.\d+$/.test(version)) return;
|
||||
if (!/^\d+\.\d+\.\d+$/.test(version)) {
|
||||
streamDeck.logger.warn(`Update check: version.json had unexpected content: ${JSON.stringify(version)}`);
|
||||
return;
|
||||
}
|
||||
if (!isNewerVersion(version, CURRENT_VERSION)) {
|
||||
streamDeck.logger.info(`Update check: up to date (v${CURRENT_VERSION}, server has v${version})`);
|
||||
sendStatus?.(`Already up to date (v${CURRENT_VERSION})`);
|
||||
return;
|
||||
}
|
||||
@@ -382,5 +390,11 @@ streamDeck.connect();
|
||||
// Initial check shortly after startup, then keep rechecking — a plugin process
|
||||
// can run for days without Stream Deck restarting, and the old code only ever
|
||||
// checked once per process lifetime.
|
||||
setTimeout(() => checkForUpdates(), 10_000);
|
||||
setInterval(() => checkForUpdates(), UPDATE_CHECK_INTERVAL_MS);
|
||||
setTimeout(() => {
|
||||
streamDeck.logger.info("Running initial (10s post-launch) update check");
|
||||
checkForUpdates();
|
||||
}, 10_000);
|
||||
setInterval(() => {
|
||||
streamDeck.logger.info("Running scheduled (30min) update check");
|
||||
checkForUpdates();
|
||||
}, UPDATE_CHECK_INTERVAL_MS);
|
||||
|
||||
Reference in New Issue
Block a user