Merge pull request #2365 from cdr/disable-update-1d93

cli: Add --disable-update-check flag
This commit is contained in:
Anmol Sethi 2020-11-30 15:47:51 -05:00 committed by GitHub
commit 7fe475c1ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 10 deletions

View File

@ -810,10 +810,10 @@ index 096b9e23493539c9937940a56e555d95bbae38d9..ef37e614004f550f7b64eacd362f6894
remove(key: string, scope: StorageScope): void { remove(key: string, scope: StorageScope): void {
diff --git a/src/vs/server/browser/client.ts b/src/vs/server/browser/client.ts diff --git a/src/vs/server/browser/client.ts b/src/vs/server/browser/client.ts
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..ead6a3cd5e98fdde074f19ee5043f152ed407146 index 0000000000000000000000000000000000000000..8a92b722b38f8743403892ea97cfb2a2a8726e3b
--- /dev/null --- /dev/null
+++ b/src/vs/server/browser/client.ts +++ b/src/vs/server/browser/client.ts
@@ -0,0 +1,240 @@ @@ -0,0 +1,241 @@
+import { Emitter } from 'vs/base/common/event'; +import { Emitter } from 'vs/base/common/event';
+import { URI } from 'vs/base/common/uri'; +import { URI } from 'vs/base/common/uri';
+import { localize } from 'vs/nls'; +import { localize } from 'vs/nls';
@ -967,8 +967,7 @@ index 0000000000000000000000000000000000000000..ead6a3cd5e98fdde074f19ee5043f152
+ +
+ const logService = (services.get(ILogService) as ILogService); + const logService = (services.get(ILogService) as ILogService);
+ const storageService = (services.get(IStorageService) as IStorageService); + const storageService = (services.get(IStorageService) as IStorageService);
+ // We set this here first in case the path changes. + const updateCheckEndpoint = path.join(options.base, '/update/check');
+ const updateCheckEndpoint = path.join(window.location.pathname, '/update/check');
+ const getUpdate = async (): Promise<void> => { + const getUpdate = async (): Promise<void> => {
+ logService.debug('Checking for update...'); + logService.debug('Checking for update...');
+ +
@ -988,8 +987,8 @@ index 0000000000000000000000000000000000000000..ead6a3cd5e98fdde074f19ee5043f152
+ +
+ const lastNoti = storageService.getNumber('csLastUpdateNotification', StorageScope.GLOBAL); + const lastNoti = storageService.getNumber('csLastUpdateNotification', StorageScope.GLOBAL);
+ if (lastNoti) { + if (lastNoti) {
+ // Only remind them again after two days. + // Only remind them again after 1 week.
+ const timeout = 1000*60*24*2; + const timeout = 1000*60*60*24*7;
+ const threshold = lastNoti + timeout; + const threshold = lastNoti + timeout;
+ if (Date.now() < threshold) { + if (Date.now() < threshold) {
+ return; + return;
@ -1008,11 +1007,13 @@ index 0000000000000000000000000000000000000000..ead6a3cd5e98fdde074f19ee5043f152
+ logService.debug(`failed to check for update: ${error}`); + logService.debug(`failed to check for update: ${error}`);
+ }).finally(() => { + }).finally(() => {
+ // Check again every 6 hours. + // Check again every 6 hours.
+ setTimeout(updateLoop, 1000*60*6); + setTimeout(updateLoop, 1000*60*60*6);
+ }); + });
+ }; + };
+ +
+ if (!options.disableUpdateCheck) {
+ updateLoop(); + updateLoop();
+ }
+ +
+ // This will be used to set the background color while VS Code loads. + // This will be used to set the background color while VS Code loads.
+ const theme = storageService.get('colorThemeData', StorageScope.GLOBAL); + const theme = storageService.get('colorThemeData', StorageScope.GLOBAL);
@ -1446,16 +1447,18 @@ index 0000000000000000000000000000000000000000..56331ff1fc32bbd82e769aaecb551e42
+require('../../bootstrap-amd').load('vs/server/entry'); +require('../../bootstrap-amd').load('vs/server/entry');
diff --git a/src/vs/server/ipc.d.ts b/src/vs/server/ipc.d.ts diff --git a/src/vs/server/ipc.d.ts b/src/vs/server/ipc.d.ts
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..0a4a91e5e36bda7f888feedda348aaff5fe32d27 index 0000000000000000000000000000000000000000..c8a613ac2db1ff154a49aa7b6da5f7d2af902ec7
--- /dev/null --- /dev/null
+++ b/src/vs/server/ipc.d.ts +++ b/src/vs/server/ipc.d.ts
@@ -0,0 +1,131 @@ @@ -0,0 +1,133 @@
+/** +/**
+ * External interfaces for integration into code-server over IPC. No vs imports + * External interfaces for integration into code-server over IPC. No vs imports
+ * should be made in this file. + * should be made in this file.
+ */ + */
+export interface Options { +export interface Options {
+ base: string
+ disableTelemetry: boolean + disableTelemetry: boolean
+ disableUpdateCheck: boolean
+} +}
+ +
+export interface InitMessage { +export interface InitMessage {

View File

@ -33,6 +33,7 @@ export interface Args extends VsArgs {
"cert-host"?: string "cert-host"?: string
"cert-key"?: string "cert-key"?: string
"disable-telemetry"?: boolean "disable-telemetry"?: boolean
"disable-update-check"?: boolean
help?: boolean help?: boolean
host?: string host?: string
json?: boolean json?: boolean
@ -114,6 +115,12 @@ const options: Options<Required<Args>> = {
}, },
"cert-key": { type: "string", path: true, description: "Path to certificate key when using non-generated cert." }, "cert-key": { type: "string", path: true, description: "Path to certificate key when using non-generated cert." },
"disable-telemetry": { type: "boolean", description: "Disable telemetry." }, "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." }, help: { type: "boolean", short: "h", description: "Show this output." },
json: { type: "boolean" }, json: { type: "boolean" },
open: { type: "boolean", description: "Open in browser on startup. Does not work remotely." }, open: { type: "boolean", description: "Open in browser on startup. Does not work remotely." },

View File

@ -42,6 +42,7 @@ router.get("/", async (req, res) => {
commit !== "development" ? content.replace(/<!-- PROD_ONLY/g, "").replace(/END_PROD_ONLY -->/g, "") : content, commit !== "development" ? content.replace(/<!-- PROD_ONLY/g, "").replace(/END_PROD_ONLY -->/g, "") : content,
{ {
disableTelemetry: !!req.args["disable-telemetry"], disableTelemetry: !!req.args["disable-telemetry"],
disableUpdateCheck: !!req.args["disable-update-check"],
}, },
) )
.replace(`"{{REMOTE_USER_DATA_URI}}"`, `'${JSON.stringify(options.remoteUserDataUri)}'`) .replace(`"{{REMOTE_USER_DATA_URI}}"`, `'${JSON.stringify(options.remoteUserDataUri)}'`)