MCPcopy Index your code
hub / github.com/coder/code-server / _getUpdate

Method _getUpdate

src/node/update.ts:51–70  ·  view source on GitHub ↗
(force?: boolean)

Source from the content-addressed store, hash-verified

49 }
50
51 private async _getUpdate(force?: boolean): Promise<Update> {
52 const now = Date.now()
53 try {
54 let { update } = !force ? await this.settings.read() : { update: undefined }
55 if (!update || update.checked + this.updateInterval < now) {
56 const buffer = await this.request(this.latestUrl)
57 const data = JSON.parse(buffer.toString()) as LatestResponse
58 update = { checked: now, version: data.name.replace(/^v/, "") }
59 await this.settings.write({ update })
60 }
61 logger.debug("got latest version", field("latest", update.version))
62 return update
63 } catch (error: any) {
64 logger.error("Failed to get latest version", field("error", error.message))
65 return {
66 checked: now,
67 version: "unknown",
68 }
69 }
70 }
71
72 /**
73 * Return true if the currently installed version is the latest.

Callers 1

getUpdateMethod · 0.95

Calls 3

requestMethod · 0.95
readMethod · 0.80
writeMethod · 0.80

Tested by

no test coverage detected