From 27f0f195a8d3c1bc66692e0cf69b752efda4ae84 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 25 Nov 2020 11:26:46 -0500 Subject: [PATCH 1/4] vscode: Use options.base for update checking See https://github.com/cdr/code-server/pull/2358#discussion_r529858749 --- ci/dev/vscode.patch | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ci/dev/vscode.patch b/ci/dev/vscode.patch index ed83c523d..9e3f5d670 100644 --- a/ci/dev/vscode.patch +++ b/ci/dev/vscode.patch @@ -813,7 +813,7 @@ new file mode 100644 index 0000000000000000000000000000000000000000..ead6a3cd5e98fdde074f19ee5043f152ed407146 --- /dev/null +++ b/src/vs/server/browser/client.ts -@@ -0,0 +1,240 @@ +@@ -0,0 +1,239 @@ +import { Emitter } from 'vs/base/common/event'; +import { URI } from 'vs/base/common/uri'; +import { localize } from 'vs/nls'; @@ -967,8 +967,7 @@ index 0000000000000000000000000000000000000000..ead6a3cd5e98fdde074f19ee5043f152 + + const logService = (services.get(ILogService) as ILogService); + const storageService = (services.get(IStorageService) as IStorageService); -+ // We set this here first in case the path changes. -+ const updateCheckEndpoint = path.join(window.location.pathname, '/update/check'); ++ const updateCheckEndpoint = path.join(options.base, "/update/check") + const getUpdate = async (): Promise => { + logService.debug('Checking for update...'); + @@ -1449,13 +1448,14 @@ new file mode 100644 index 0000000000000000000000000000000000000000..0a4a91e5e36bda7f888feedda348aaff5fe32d27 --- /dev/null +++ b/src/vs/server/ipc.d.ts -@@ -0,0 +1,131 @@ +@@ -0,0 +1,132 @@ +/** + * External interfaces for integration into code-server over IPC. No vs imports + * should be made in this file. + */ +export interface Options { + disableTelemetry: boolean ++ base: string +} + +export interface InitMessage { From cc18175ce3bde6da56f507a4fb66e6a1e5524f00 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 25 Nov 2020 11:37:40 -0500 Subject: [PATCH 2/4] cli: Add --disable-update-check flag Closes #2361 --- ci/dev/vscode.patch | 17 ++++++++++------- src/node/cli.ts | 7 +++++++ src/node/routes/vscode.ts | 1 + 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/ci/dev/vscode.patch b/ci/dev/vscode.patch index 9e3f5d670..b88639c77 100644 --- a/ci/dev/vscode.patch +++ b/ci/dev/vscode.patch @@ -813,7 +813,7 @@ new file mode 100644 index 0000000000000000000000000000000000000000..ead6a3cd5e98fdde074f19ee5043f152ed407146 --- /dev/null +++ b/src/vs/server/browser/client.ts -@@ -0,0 +1,239 @@ +@@ -0,0 +1,241 @@ +import { Emitter } from 'vs/base/common/event'; +import { URI } from 'vs/base/common/uri'; +import { localize } from 'vs/nls'; @@ -967,7 +967,7 @@ index 0000000000000000000000000000000000000000..ead6a3cd5e98fdde074f19ee5043f152 + + const logService = (services.get(ILogService) as ILogService); + const storageService = (services.get(IStorageService) as IStorageService); -+ const updateCheckEndpoint = path.join(options.base, "/update/check") ++ const updateCheckEndpoint = path.join(options.base, "/update/check"); + const getUpdate = async (): Promise => { + logService.debug('Checking for update...'); + @@ -987,8 +987,8 @@ index 0000000000000000000000000000000000000000..ead6a3cd5e98fdde074f19ee5043f152 + + const lastNoti = storageService.getNumber('csLastUpdateNotification', StorageScope.GLOBAL); + if (lastNoti) { -+ // Only remind them again after two days. -+ const timeout = 1000*60*24*2; ++ // Only remind them again after 1 week. ++ const timeout = 1000*60*24*7; + const threshold = lastNoti + timeout; + if (Date.now() < threshold) { + return; @@ -1011,7 +1011,9 @@ index 0000000000000000000000000000000000000000..ead6a3cd5e98fdde074f19ee5043f152 + }); + }; + -+ updateLoop(); ++ if (!options.disableUpdateCheck) { ++ updateLoop(); ++ } + + // This will be used to set the background color while VS Code loads. + const theme = storageService.get('colorThemeData', StorageScope.GLOBAL); @@ -1448,14 +1450,15 @@ new file mode 100644 index 0000000000000000000000000000000000000000..0a4a91e5e36bda7f888feedda348aaff5fe32d27 --- /dev/null +++ b/src/vs/server/ipc.d.ts -@@ -0,0 +1,132 @@ +@@ -0,0 +1,133 @@ +/** + * External interfaces for integration into code-server over IPC. No vs imports + * should be made in this file. + */ +export interface Options { -+ disableTelemetry: boolean + base: string ++ disableTelemetry: boolean ++ disableUpdateCheck: boolean +} + +export interface InitMessage { diff --git a/src/node/cli.ts b/src/node/cli.ts index 23a6bc146..571f39584 100644 --- a/src/node/cli.ts +++ b/src/node/cli.ts @@ -33,6 +33,7 @@ export interface Args extends VsArgs { "cert-host"?: string "cert-key"?: string "disable-telemetry"?: boolean + "disable-update-check"?: boolean help?: boolean host?: string json?: boolean @@ -114,6 +115,12 @@ const options: Options> = { }, "cert-key": { type: "string", path: true, description: "Path to certificate key when using non-generated cert." }, "disable-telemetry": { type: "boolean", description: "Disable telemetry." }, + "disable-update-check": { + type: "boolean", + description: + "Disable update check. Without this flag, code-server checks every 6 hours against the latest github release and \n" + + "then notifies you once every week that a new release is available.", + }, help: { type: "boolean", short: "h", description: "Show this output." }, json: { type: "boolean" }, open: { type: "boolean", description: "Open in browser on startup. Does not work remotely." }, diff --git a/src/node/routes/vscode.ts b/src/node/routes/vscode.ts index 9b464f61e..373dd4ce7 100644 --- a/src/node/routes/vscode.ts +++ b/src/node/routes/vscode.ts @@ -42,6 +42,7 @@ router.get("/", async (req, res) => { commit !== "development" ? content.replace(//g, "") : content, { disableTelemetry: !!req.args["disable-telemetry"], + disableUpdateCheck: !!req.args["disable-update-check"], }, ) .replace(`"{{REMOTE_USER_DATA_URI}}"`, `'${JSON.stringify(options.remoteUserDataUri)}'`) From 0713fa900bf6af47f60aa3eb0c15f76d1a930ef0 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 25 Nov 2020 11:50:38 -0500 Subject: [PATCH 3/4] vscode: Fix update check timeouts Forgot an extra 60 in the check interval and the notification timeout. Very unfortunate. Check has been allowed every 168 minutes instead of every week. --- ci/dev/vscode.patch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/dev/vscode.patch b/ci/dev/vscode.patch index b88639c77..40d6789e0 100644 --- a/ci/dev/vscode.patch +++ b/ci/dev/vscode.patch @@ -988,7 +988,7 @@ index 0000000000000000000000000000000000000000..ead6a3cd5e98fdde074f19ee5043f152 + const lastNoti = storageService.getNumber('csLastUpdateNotification', StorageScope.GLOBAL); + if (lastNoti) { + // Only remind them again after 1 week. -+ const timeout = 1000*60*24*7; ++ const timeout = 1000*60*60*24*7; + const threshold = lastNoti + timeout; + if (Date.now() < threshold) { + return; @@ -1007,7 +1007,7 @@ index 0000000000000000000000000000000000000000..ead6a3cd5e98fdde074f19ee5043f152 + logService.debug(`failed to check for update: ${error}`); + }).finally(() => { + // Check again every 6 hours. -+ setTimeout(updateLoop, 1000*60*6); ++ setTimeout(updateLoop, 1000*60*60*6); + }); + }; + From 261af28f70aa217bc8c4993c07cccb01671840dc Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Mon, 30 Nov 2020 15:39:57 -0500 Subject: [PATCH 4/4] vscode: Fixes for linting --- ci/dev/vscode.patch | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/dev/vscode.patch b/ci/dev/vscode.patch index 40d6789e0..d9dcd04e0 100644 --- a/ci/dev/vscode.patch +++ b/ci/dev/vscode.patch @@ -810,7 +810,7 @@ index 096b9e23493539c9937940a56e555d95bbae38d9..ef37e614004f550f7b64eacd362f6894 remove(key: string, scope: StorageScope): void { diff --git a/src/vs/server/browser/client.ts b/src/vs/server/browser/client.ts new file mode 100644 -index 0000000000000000000000000000000000000000..ead6a3cd5e98fdde074f19ee5043f152ed407146 +index 0000000000000000000000000000000000000000..8a92b722b38f8743403892ea97cfb2a2a8726e3b --- /dev/null +++ b/src/vs/server/browser/client.ts @@ -0,0 +1,241 @@ @@ -967,7 +967,7 @@ index 0000000000000000000000000000000000000000..ead6a3cd5e98fdde074f19ee5043f152 + + const logService = (services.get(ILogService) as ILogService); + const storageService = (services.get(IStorageService) as IStorageService); -+ const updateCheckEndpoint = path.join(options.base, "/update/check"); ++ const updateCheckEndpoint = path.join(options.base, '/update/check'); + const getUpdate = async (): Promise => { + logService.debug('Checking for update...'); + @@ -1447,7 +1447,7 @@ index 0000000000000000000000000000000000000000..56331ff1fc32bbd82e769aaecb551e42 +require('../../bootstrap-amd').load('vs/server/entry'); diff --git a/src/vs/server/ipc.d.ts b/src/vs/server/ipc.d.ts new file mode 100644 -index 0000000000000000000000000000000000000000..0a4a91e5e36bda7f888feedda348aaff5fe32d27 +index 0000000000000000000000000000000000000000..c8a613ac2db1ff154a49aa7b6da5f7d2af902ec7 --- /dev/null +++ b/src/vs/server/ipc.d.ts @@ -0,0 +1,133 @@