Skip to content

Commit 848d8de

Browse files
committed
Use truncated version with signature fallback
1 parent c26018f commit 848d8de

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/storage.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import fs from "fs/promises";
88
import { IncomingMessage } from "http";
99
import path from "path";
1010
import prettyBytes from "pretty-bytes";
11+
import * as semver from "semver";
1112
import * as vscode from "vscode";
1213
import { errToStr } from "./api-helper";
1314
import * as cli from "./cliManager";
@@ -139,6 +140,10 @@ export class Storage {
139140
// and to log for debugging.
140141
const buildInfo = await restClient.getBuildInfo();
141142
this.output.info("Got server version", buildInfo.version);
143+
const parsedVersion = semver.parse(buildInfo.version);
144+
if (!parsedVersion) {
145+
throw new Error(`Got invalid version from deployment: ${buildInfo.version}`)
146+
}
142147

143148
// Check if there is an existing binary and whether it looks valid. If it
144149
// is valid and matches the server, or if it does not match the server but
@@ -230,9 +235,11 @@ export class Storage {
230235
// named exactly the same with an appended `.asc` (such as
231236
// coder-windows-amd64.exe.asc or coder-linux-amd64.asc).
232237
binSource + ".asc",
233-
// The releases.coder.com bucket does not include the leading "v".
234-
// The signature name follows the same rule as above.
235-
`https://releases.coder.com/coder-cli/${buildInfo.version.replace(/^v/, "")}/${binName}.asc`,
238+
// The releases.coder.com bucket does not include the leading "v",
239+
// and unlike what we get from buildinfo it uses a truncated version
240+
// with only major.minor.patch. The signature name follows the same
241+
// rule as above.
242+
`https://releases.coder.com/coder-cli/${parsedVersion.major}.${parsedVersion.minor}.${parsedVersion.patch}/${binName}.asc`,
236243
]);
237244
}
238245

0 commit comments

Comments
 (0)