Skip to content

Use local filesystem instead of browser storage #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/vs/server/webClientServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ export class WebClientServer {
webEndpointUrl: vscodeBase + '/static',
webEndpointUrlTemplate: vscodeBase + '/static',
webviewContentExternalBaseUrlTemplate: vscodeBase + '/webview/{{uuid}}/',

updateUrl: base + '/update/check'
},
folderUri: (workspacePath && isFolder) ? transformer.transformOutgoing(URI.file(workspacePath)) : undefined,
Expand All @@ -351,6 +350,7 @@ export class WebClientServer {
logLevel: this._logService.getLevel(),
},
ignoreLastOpened: this._environmentService.ignoreLastOpened,
userDataPath: this._environmentService.userDataPath,
settingsSyncOptions: !this._environmentService.isBuilt && this._environmentService.args['enable-sync'] ? { enabled: true } : undefined,
})))
.replace(/{{CLIENT_BACKGROUND_COLOR}}/g, () => backgroundColor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,19 @@ export class BrowserWorkbenchEnvironmentService implements IWorkbenchEnvironment
@memoize
get logFile(): URI { return joinPath(this.options.logsPath, 'window.log'); }

/**
* Use the local disk. This solves two problems:
* 1. Extensions running in the browser (like Vim) might use these paths
* directly instead of using the file service and most likely can't write
* to `/User` on disk.
* 2. Settings will be stored in the file system instead of in browser
* storage. Using browser storage makes sharing or seeding settings
* between browsers difficult. We may want to revisit this once/if we get
* settings sync.
* @author coder
*/
@memoize
get userRoamingDataHome(): URI { return URI.file('/User').with({ scheme: Schemas.userData }); }
get userRoamingDataHome(): URI { return joinPath(URI.file(this.userDataPath).with({ scheme: Schemas.vscodeRemote }), 'User'); }

@memoize
get settingsResource(): URI { return joinPath(this.userRoamingDataHome, 'settings.json'); }
Expand Down Expand Up @@ -256,7 +267,12 @@ export class BrowserWorkbenchEnvironmentService implements IWorkbenchEnvironment
get ignoreLastOpened(): boolean {
return !!this.options.ignoreLastOpened;
}

get userDataPath(): string {
if (!this.options.userDataPath) {
throw new Error('userDataPath was not provided to the browser');
}
return this.options.userDataPath;
}
//#endregion

private payload: Map<string, string> | undefined;
Expand Down
4 changes: 4 additions & 0 deletions src/vs/workbench/workbench.web.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,10 @@ interface IWorkbenchConstructionOptions {
* @see `BrowserMain#initServices`
*/
readonly ignoreLastOpened?: boolean
/**
* Path to the user data directory.
*/
readonly userDataPath?: string

//#endregion

Expand Down