userDataSyncService.ts ×22

Frontier kind: Code frontier

unlabeled · c_2f2e613079a1

131 tests · 25829 LOC · 133 files · introduces 0 tests · 84 LOC · 3 files

Introduces — evidence that enters the hierarchy at this concept

Code
26 ranges84 lines · 3 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
4141 ranges25829 lines · 133 files · Browse complete extent
All tests (intent)
131 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: 84 introduced LOC across 26 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/userDataSync/common/userDataSyncService.ts 76 introduced LOC · 22 ranges

Open complete file

118
119 async createSyncTask(manifest: IUserDataManifest | null, disableCache?: boolean): Promise<IUserDataSyncTask> {
120 > this.checkEnablement(); userDataSyncService.ts
121 >
122 > this.logService.info('Sync started.');
123 > const startTime = new Date().getTime();
124 > const executionId = generateUuid();
125 > try {
126 > const syncHeaders = createSyncHeaders(executionId);
127 > if (disableCache) {
128 syncHeaders['Cache-Control'] = 'no-cache';
129 }
130 > manifest = await this.userDataSyncStoreService.manifest(manifest, syncHeaders); userDataSyncService.ts
131 > } catch (error) {
132 const userDataSyncError = UserDataSyncError.toUserDataSyncError(error);
133 reportUserDataSyncError(userDataSyncError, executionId, this.userDataSyncStoreManagementService, this.telemetryService);
134 throw userDataSyncError;
135 }
137 > const executed = false;
138 > const that = this;
139 > let cancellablePromise: CancelablePromise<void> | undefined;
140 > return {
141 > manifest,
142 > async run(): Promise<void> {
143 > if (executed) {
144 throw new Error('Can run a task only once');
145 }
146 > cancellablePromise = createCancelablePromise(token => that.sync(manifest, false, executionId, token)); userDataSyncService.ts
147 > await cancellablePromise.finally(() => cancellablePromise = undefined);
148 that.logService.info(`Sync done. Took ${new Date().getTime() - startTime}ms`);
149 that.updateLastSyncTime();
151 > stop(): Promise<void> {
152 cancellablePromise?.cancel();
153 return that.stop();
154 }
156 > }
157
158 async createManualSyncTask(): Promise<IUserDataManualSyncTask> {
232
233 private async sync(manifestOrLatestData: IUserDataManifest | IUserDataSyncLatestData | null, preview: boolean, executionId: string, token: CancellationToken): Promise<void> {
234 > this._syncErrors = []; userDataSyncService.ts
235 > try {
236 > if (this.status !== SyncStatus.HasConflicts) {
237 > this.setStatus(SyncStatus.Syncing);
238 > }
239 >
240 > // Sync Default Profile First
241 > const defaultProfileSynchronizer = this.getOrCreateActiveProfileSynchronizer(this.userDataProfilesService.defaultProfile, undefined);
242 > this._syncErrors.push(...await this.syncProfile(defaultProfileSynchronizer, manifestOrLatestData, preview, executionId, token));
243
244 // Sync other profiles
251 await this.syncRemoteProfiles(syncProfiles, manifestOrLatestData, preview, executionId, token);
252 }
253 > } finally { userDataSyncService.ts
254 > if (this.status !== SyncStatus.HasConflicts) {
255 > this.setStatus(SyncStatus.Idle);
256 > }
257 > this._onSyncErrors.fire(this._syncErrors);
258 > }
259 > }
260
261 private async syncRemoteProfiles(remoteProfiles: ISyncUserDataProfile[], manifest: IUserDataManifest | IUserDataSyncLatestData | null, preview: boolean, executionId: string, token: CancellationToken): Promise<void> {
317
318 private async syncProfile(profileSynchronizer: ProfileSynchronizer, manifestOrLatestData: IUserDataManifest | IUserDataSyncLatestData | null, preview: boolean, executionId: string, token: CancellationToken): Promise<IUserDataSyncResourceError[]> {
319 > const errors = await profileSynchronizer.sync(manifestOrLatestData, preview, executionId, token); userDataSyncService.ts
320 return errors.map(([syncResource, error]) => ({ profile: profileSynchronizer.profile, syncResource, error }));
322
323 private async stop(): Promise<void> {
638
639 private checkEnablement(): void {
640 > if (!this.userDataSyncStoreManagementService.userDataSyncStore) { userDataSyncService.ts
641 throw new Error('Not enabled');
642 }
644
645 }
749
750 async sync(manifestOrLatestData: IUserDataManifest | IUserDataSyncLatestData | null, preview: boolean, executionId: string, token: CancellationToken): Promise<[SyncResource, UserDataSyncError][]> {
752 > // Return if cancellation is requested
753 > if (token.isCancellationRequested) {
754 return [];
755 }
757 > const synchronizers = this.enabled;
758 > if (!synchronizers.length) {
759 return [];
760 }
762 > try {
763 > const syncErrors: [SyncResource, UserDataSyncError][] = [];
764 > const syncHeaders = createSyncHeaders(executionId);
765 > const userDataSyncConfiguration = preview ? await this.getUserDataSyncConfiguration(manifestOrLatestData) : this.getLocalUserDataSyncConfiguration();
766 > for (const synchroniser of synchronizers) {
767 > // Return if cancellation is requested
768 > if (token.isCancellationRequested) {
769 return [];
770 }
772 > // Return if resource is not enabled
773 > if (!this.userDataSyncEnablementService.isResourceEnabled(synchroniser.resource)) {
774 return [];
775 }
777 > try {
778 > const refOrUserData = getRefOrUserData(manifestOrLatestData, this.collection, synchroniser.resource) ?? null;
779 > await synchroniser.sync(refOrUserData, preview, userDataSyncConfiguration, syncHeaders);
780 > } catch (e) {
781 const userDataSyncError = UserDataSyncError.toUserDataSyncError(e);
782 reportUserDataSyncError(userDataSyncError, executionId, this.userDataSyncStoreManagementService, this.telemetryService);
790 syncErrors.push([synchroniser.resource, userDataSyncError]);
791 }
793
794 return syncErrors;
795 > } finally { userDataSyncService.ts
796 > this.updateStatus();
797 > }
798 > }
799
800 async apply(executionId: string, token: CancellationToken): Promise<void> {
857
858 private getLocalUserDataSyncConfiguration(): IUserDataSyncConfiguration {
859 > return this.configurationService.getValue(USER_DATA_SYNC_CONFIGURATION_SCOPE); userDataSyncService.ts
860 > }
861
862 private setStatus(status: SyncStatus): void {
935 }
936
937 > function getRefOrUserData(manifestOrLatestData: IUserDataManifest | IUserDataSyncLatestData | null, collection: string | undefined, resource: SyncResource): string | IUserData | undefined { userDataSyncService.ts
938 > if (isUserDataManifest(manifestOrLatestData)) {
939 if (collection) {
940 return manifestOrLatestData?.collections?.[collection]?.latest?.[resource];
src/vs/platform/userDataSync/common/userDataSync.ts 6 introduced LOC · 3 ranges

Open complete file

205
206 export function isUserDataManifest(thing: any): thing is IUserDataManifest {
207 > return thing userDataSync.ts
208 && isString(thing.session)
209 && isString(thing.ref)
210 && (isObject(thing.latest) || thing.latest === undefined)
211 && (isObject(thing.collections) || thing.collections === undefined);
212 > } userDataSync.ts
213
214 export interface IUserDataSyncActivityData {
294
295 export function createSyncHeaders(executionId: string): IHeaders {
296 > const headers: IHeaders = {}; userDataSync.ts
297 > headers[HEADER_EXECUTION_ID] = executionId;
298 > return headers;
299 > }
300
301 //#endregion
src/vs/base/common/async.ts 2 introduced LOC · 1 range

Open complete file

76 }
77 finally(onfinally?: (() => void) | undefined | null): Promise<T> {
78 > return promise.finally(onfinally); async.ts
79 > }
80 };
81 }