userDataProfilesManifestSync.ts ×8

Frontier kind: Code frontier

unlabeled · c_9115e12526d5

130 tests · 25404 LOC · 133 files · introduces 0 tests · 50 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
8 ranges50 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
4030 ranges25404 lines · 133 files · Browse complete extent
All tests (intent)
130 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.

1 file ranked by introduced lines: 50 introduced LOC across 8 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/userDataSync/common/userDataProfilesManifestSync.ts 50 introduced LOC · 8 ranges

Open complete file

68
69 protected async generateSyncPreview(remoteUserData: IRemoteUserData, lastSyncUserData: IRemoteUserData | null, isRemoteDataFromCurrentMachine: boolean): Promise<IUserDataProfilesManifestResourcePreview[]> {
70 > const remoteProfiles: ISyncUserDataProfile[] | null = remoteUserData.syncData ? parseUserDataProfilesManifest(remoteUserData.syncData) : null; userDataProfilesManifestSync.ts
71 > const lastSyncProfiles: ISyncUserDataProfile[] | null = lastSyncUserData?.syncData ? parseUserDataProfilesManifest(lastSyncUserData.syncData) : null;
72 > const localProfiles = this.getLocalUserDataProfiles();
73 >
74 > const { local, remote } = merge(localProfiles, remoteProfiles, lastSyncProfiles, []);
75 > const previewResult: IUserDataProfileManifestResourceMergeResult = {
76 > local, remote,
77 > content: lastSyncProfiles ? this.stringifyRemoteProfiles(lastSyncProfiles) : null,
78 > localChange: local.added.length > 0 || local.removed.length > 0 || local.updated.length > 0 ? Change.Modified : Change.None,
79 > remoteChange: remote !== null ? Change.Modified : Change.None,
80 > };
81 >
82 > const localContent = stringifyLocalProfiles(localProfiles, false);
83 > return [{
84 > baseResource: this.baseResource,
85 > baseContent: lastSyncProfiles ? this.stringifyRemoteProfiles(lastSyncProfiles) : null,
86 > localResource: this.localResource,
87 > localContent,
88 > remoteResource: this.remoteResource,
89 > remoteContent: remoteProfiles ? this.stringifyRemoteProfiles(remoteProfiles) : null,
90 > remoteProfiles,
91 > previewResource: this.previewResource,
92 > previewResult,
93 > localChange: previewResult.localChange,
94 > remoteChange: previewResult.remoteChange,
95 > acceptedResource: this.acceptedResource
96 > }];
97 > }
98
99 protected async hasRemoteChanged(lastSyncUserData: IRemoteUserData): Promise<boolean> {
173
174 protected async applyResult(remoteUserData: IRemoteUserData, lastSyncUserData: IRemoteUserData | null, resourcePreviews: [IUserDataProfilesManifestResourcePreview, IUserDataProfileManifestResourceMergeResult][], force: boolean): Promise<void> {
175 > const { local, remote, localChange, remoteChange } = resourcePreviews[0][1]; userDataProfilesManifestSync.ts
176 > if (localChange === Change.None && remoteChange === Change.None) {
177 this.logService.info(`${this.syncResourceLogLabel}: No changes found during synchronizing profiles.`);
178 }
180 > const remoteProfiles = resourcePreviews[0][0].remoteProfiles || [];
181 > if (remoteProfiles.length + (remote?.added.length ?? 0) - (remote?.removed.length ?? 0) > 20) {
182 throw new UserDataSyncError('Too many profiles to sync. Please remove some profiles and try again.', UserDataSyncErrorCode.LocalTooManyProfiles);
183 }
185 > if (localChange !== Change.None) {
186 await this.backupLocal(stringifyLocalProfiles(this.getLocalUserDataProfiles(), false));
187 await Promise.all(local.removed.map(async profile => {
206 }));
207 }
209 > if (remoteChange !== Change.None) {
210 this.logService.trace(`${this.syncResourceLogLabel}: Updating remote profiles...`);
211 const addedCollections: string[] = [];
248 }
249 }
251 > if (lastSyncUserData?.ref !== remoteUserData.ref) {
252 > // update last sync
253 > this.logService.trace(`${this.syncResourceLogLabel}: Updating last synchronized profiles...`);
254 > await this.updateLastSyncUserData(remoteUserData);
255 > this.logService.info(`${this.syncResourceLogLabel}: Updated last synchronized profiles.`);
256 > }
257 > }
258
259 async updateRemoteProfiles(profiles: ISyncUserDataProfile[], ref: string | null): Promise<IRemoteUserData> {
278
279 private getLocalUserDataProfiles(): IUserDataProfile[] {
280 > return this.userDataProfilesService.profiles.filter(p => !p.isDefault && !p.isTransient); userDataProfilesManifestSync.ts
281 > }
282
283 private stringifyRemoteProfiles(profiles: ISyncUserDataProfile[]): string {
288
289 export function stringifyLocalProfiles(profiles: IUserDataProfile[], format: boolean): string {
290 > const result = [...profiles].sort((a, b) => a.name.localeCompare(b.name)).map(p => ({ id: p.id, name: p.name })); userDataProfilesManifestSync.ts
291 > return format ? toFormattedString(result, {}) : JSON.stringify(result);
292 > }
293
294 export function parseUserDataProfilesManifest(syncData: ISyncData): ISyncUserDataProfile[] {