|
| 1 | +Make storage local to the remote server |
| 2 | + |
| 3 | +This makes user settings will be stored in the file system instead of in browser |
| 4 | +storage. Using browser storage makes sharing or seeding settings between |
| 5 | +browsers difficult and remote settings is not a sufficient replacement because |
| 6 | +some settings are only allowed to be set on the user level. |
| 7 | + |
| 8 | +Unfortunately this does not affect state which uses a separate method with |
| 9 | +IndexedDB and does not appear nearly as easy to redirect to disk. |
| 10 | + |
| 11 | +To test change settings from the UI and on disk while making sure they appear on |
| 12 | +the other side. |
| 13 | + |
| 14 | +This patch also resolves a bug where a global value for workspace initialization |
| 15 | +is used in a non async-safe way. |
| 16 | + |
| 17 | +Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts |
| 18 | +=================================================================== |
| 19 | +--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts |
| 20 | ++++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts |
| 21 | +@@ -327,6 +327,7 @@ export class WebClientServer { |
| 22 | + const workbenchWebConfiguration = { |
| 23 | + remoteAuthority, |
| 24 | + webviewEndpoint: vscodeBase + this._staticRoute + '/out/vs/workbench/contrib/webview/browser/pre', |
| 25 | ++ userDataPath: this._environmentService.userDataPath, |
| 26 | + _wrapWebWorkerExtHostInIframe, |
| 27 | + developmentOptions: { enableSmokeTestDriver: this._environmentService.args['enable-smoke-test-driver'] ? true : undefined, logLevel: this._logService.getLevel() }, |
| 28 | + settingsSyncOptions: !this._environmentService.isBuilt && this._environmentService.args['enable-sync'] ? { enabled: true } : undefined, |
| 29 | +Index: code-server/lib/vscode/src/vs/workbench/browser/web.api.ts |
| 30 | +=================================================================== |
| 31 | +--- code-server.orig/lib/vscode/src/vs/workbench/browser/web.api.ts |
| 32 | ++++ code-server/lib/vscode/src/vs/workbench/browser/web.api.ts |
| 33 | +@@ -276,6 +276,11 @@ export interface IWorkbenchConstructionO |
| 34 | + */ |
| 35 | + readonly configurationDefaults?: Record<string, any>; |
| 36 | + |
| 37 | ++ /** |
| 38 | ++ * Path to the user data directory. |
| 39 | ++ */ |
| 40 | ++ readonly userDataPath?: string |
| 41 | ++ |
| 42 | + //#endregion |
| 43 | + |
| 44 | + //#region Profile options |
| 45 | +Index: code-server/lib/vscode/src/vs/workbench/services/environment/browser/environmentService.ts |
| 46 | +=================================================================== |
| 47 | +--- code-server.orig/lib/vscode/src/vs/workbench/services/environment/browser/environmentService.ts |
| 48 | ++++ code-server/lib/vscode/src/vs/workbench/services/environment/browser/environmentService.ts |
| 49 | +@@ -102,7 +102,14 @@ export class BrowserWorkbenchEnvironment |
| 50 | + get logFile(): URI { return joinPath(this.windowLogsPath, 'window.log'); } |
| 51 | + |
| 52 | + @memoize |
| 53 | +- get userRoamingDataHome(): URI { return URI.file('/User').with({ scheme: Schemas.vscodeUserData }); } |
| 54 | ++ get userRoamingDataHome(): URI { return joinPath(URI.file(this.userDataPath).with({ scheme: Schemas.vscodeRemote }), 'User'); } |
| 55 | ++ |
| 56 | ++ get userDataPath(): string { |
| 57 | ++ if (!this.options.userDataPath) { |
| 58 | ++ throw new Error('userDataPath was not provided to the browser'); |
| 59 | ++ } |
| 60 | ++ return this.options.userDataPath; |
| 61 | ++ } |
| 62 | + |
| 63 | + @memoize |
| 64 | + get argvResource(): URI { return joinPath(this.userRoamingDataHome, 'argv.json'); } |
| 65 | +Index: code-server/lib/vscode/src/vs/workbench/services/configuration/browser/configurationService.ts |
| 66 | +=================================================================== |
| 67 | +--- code-server.orig/lib/vscode/src/vs/workbench/services/configuration/browser/configurationService.ts |
| 68 | ++++ code-server/lib/vscode/src/vs/workbench/services/configuration/browser/configurationService.ts |
| 69 | +@@ -143,8 +143,10 @@ export class WorkspaceService extends Di |
| 70 | + this.workspaceConfiguration = this._register(new WorkspaceConfiguration(configurationCache, fileService, uriIdentityService, logService)); |
| 71 | + this._register(this.workspaceConfiguration.onDidUpdateConfiguration(fromCache => { |
| 72 | + this.onWorkspaceConfigurationChanged(fromCache).then(() => { |
| 73 | +- this.workspace.initialized = this.workspaceConfiguration.initialized; |
| 74 | +- this.checkAndMarkWorkspaceComplete(fromCache); |
| 75 | ++ if (this.workspace) { // The workspace may not have been created yet. |
| 76 | ++ this.workspace.initialized = this.workspaceConfiguration.initialized; |
| 77 | ++ this.checkAndMarkWorkspaceComplete(fromCache); |
| 78 | ++ } |
| 79 | + }); |
| 80 | + })); |
| 81 | + |
| 82 | +@@ -550,6 +552,8 @@ export class WorkspaceService extends Di |
| 83 | + previousFolders = this.workspace.folders; |
| 84 | + this.workspace.update(workspace); |
| 85 | + } else { |
| 86 | ++ // The configuration could have updated before the promise resolved. |
| 87 | ++ workspace.initialized = this.workspaceConfiguration.initialized; |
| 88 | + this.workspace = workspace; |
| 89 | + } |
| 90 | + |
0 commit comments