userDataSyncStoreService.ts ×10

Frontier kind: Code frontier

unlabeled · c_8029d3465dfb

248 tests · 24503 LOC · 133 files · introduces 0 tests · 47 LOC · 3 files

Introduces — evidence that enters the hierarchy at this concept

Code
17 ranges47 lines · 3 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
3797 ranges24503 lines · 133 files · Browse complete extent
All tests (intent)
248 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

3 files ranked by introduced lines: 47 introduced LOC across 17 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/userDataSync/common/userDataSyncStoreService.ts 32 introduced LOC · 10 ranges

Open complete file

407
408 async manifest(oldValue: IUserDataManifest | null, headers: IHeaders = {}): Promise<IUserDataManifest | null> {
409 > if (!this.userDataSyncStoreUrl) { userDataSyncStoreService.ts
410 throw new Error('No settings sync store url configured.');
411 }
413 > const url = joinPath(this.userDataSyncStoreUrl, 'manifest').toString();
414 > headers = { ...headers };
415 > headers['Content-Type'] = 'application/json';
416 > if (oldValue) {
417 headers['If-None-Match'] = oldValue.ref;
418 }
420 > const context = await this.request(url, { type: 'GET', headers, callSite: 'userDataSync.manifest' }, [304], CancellationToken.None);
421 >
422 > let manifest: IUserDataManifest | null = null;
423 > if (context.res.statusCode === 304) {
424 manifest = oldValue;
425 }
427 > if (!manifest) {
428 > const ref = context.res.headers['etag'];
429 > if (!ref) {
430 throw new UserDataSyncStoreError('Server did not return the ref', url, UserDataSyncErrorCode.NoRef, context.res.statusCode, context.res.headers[HEADER_OPERATION_ID]);
431 }
433 > const content = await asTextOrError(context);
434 > if (!content && context.res.statusCode === 304) {
435 throw new UserDataSyncStoreError('Empty response', url, UserDataSyncErrorCode.EmptyResponse, context.res.statusCode, context.res.headers[HEADER_OPERATION_ID]);
436 }
438 > if (content) {
439 manifest = { ...JSON.parse(content), ref };
440 }
442 >
443 > const currentSessionId = this.storageService.get(USER_SESSION_ID_KEY, StorageScope.APPLICATION);
444 >
445 > if (currentSessionId && manifest && currentSessionId !== manifest.session) {
446 // Server session is different from client session so clear cached session.
447 this.clearSession();
448 }
450 > if (manifest === null && currentSessionId) {
451 // server session is cleared so clear cached session.
452 this.clearSession();
453 }
455 > if (manifest) {
456 // update session
457 this.storageService.store(USER_SESSION_ID_KEY, manifest.session, StorageScope.APPLICATION, StorageTarget.MACHINE);
458 }
460 > return manifest;
461 > }
462
463 async clear(): Promise<void> {
src/vs/platform/request/common/request.ts 10 introduced LOC · 4 ranges

Open complete file

164
165 export function hasNoContent(context: IRequestContext): boolean {
166 > return context.res.statusCode === 204; request.ts
167 > }
168
169 > export async function asText(context: IRequestContext): Promise<string | null> { request.ts
170 > if (hasNoContent(context)) {
171 > return null;
172 > }
173 const buffer = await streamToBuffer(context.stream);
174 return buffer.toString();
175 }
176
177 > export async function asTextOrError(context: IRequestContext): Promise<string | null> { request.ts
178 > if (!isSuccess(context)) {
179 throw new Error('Server returned ' + context.res.statusCode);
180 }
181 > return asText(context); request.ts
182 > }
183
184 export async function asJson<T = {}>(context: IRequestContext): Promise<T | null> {
src/vs/platform/userDataSync/test/common/userDataSyncClient.ts 5 introduced LOC · 3 ranges

Open complete file

234 const segments = relativePath ? relativePath.split('/') : [];
235 if (options.type === 'GET' && segments.length === 1 && segments[0] === 'manifest') {
236 > return this.getManifest(options.headers); userDataSyncClient.ts
237 > }
238 if (options.type === 'GET' && segments.length === 3 && segments[0] === 'resource') {
239 return this.getResourceData(undefined, segments[1], segments[2] === 'latest' ? undefined : segments[2], options.headers);
265
266 private async getManifest(headers?: IHeaders): Promise<IRequestContext> {
267 > if (this.session) { userDataSyncClient.ts
268 const latest: Record<ServerResource, string> = Object.create({});
269 this.data.forEach((value, key) => latest[key] = value.ref);
283 return this.toResponse(200, { 'Content-Type': 'application/json', etag: `${this.manifestRef++}` }, JSON.stringify(manifest));
284 }
285 > return this.toResponse(204, { etag: `${this.manifestRef++}` }); userDataSyncClient.ts
286 > }
287
288 private async getResourceData(collection: string | undefined, resource: string, ref?: string, headers: IHeaders = {}): Promise<IRequestContext> {