abstractJsonSynchronizer.ts ×8

Frontier kind: Code frontier

unlabeled · c_1b60e6bbf9e9

141 tests · 25255 LOC · 133 files · introduces 0 tests · 56 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
8 ranges56 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
3963 ranges25255 lines · 133 files · Browse complete extent
All tests (intent)
141 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: 56 introduced LOC across 8 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/userDataSync/common/abstractJsonSynchronizer.ts 56 introduced LOC · 8 ranges

Open complete file

58
59 protected async generateSyncPreview(remoteUserData: IRemoteUserData, lastSyncUserData: IRemoteUserData | null, isRemoteDataFromCurrentMachine: boolean, userDataSyncConfiguration: IUserDataSyncConfiguration): Promise<IJsonResourcePreview[]> {
60 > const remoteContent = remoteUserData.syncData ? this.getContentFromSyncContent(remoteUserData.syncData.content) : null; abstractJsonSynchronizer.ts
61 >
62 > // Use remote data as last sync data if last sync data does not exist and remote data is from same machine
63 > lastSyncUserData = lastSyncUserData === null && isRemoteDataFromCurrentMachine ? remoteUserData : lastSyncUserData;
64 > const lastSyncContent: string | null = lastSyncUserData?.syncData ? this.getContentFromSyncContent(lastSyncUserData.syncData.content) : null;
65 >
66 > // Get file content last to get the latest
67 > const fileContent = await this.getLocalFileContent();
68 >
69 > let content: string | null = null;
70 > let hasLocalChanged: boolean = false;
71 > let hasRemoteChanged: boolean = false;
72 > let hasConflicts: boolean = false;
73 >
74 > if (remoteUserData.syncData) {
75 const localContent = fileContent ? fileContent.value.toString() : null;
76 if (!lastSyncContent // First time sync
86 }
87 }
89 > // First time syncing to remote
90 > else if (fileContent) {
91 this.logService.trace(`${this.syncResourceLogLabel}: Remote ${this.syncResource.syncResource} does not exist. Synchronizing ${this.syncResource.syncResource} for the first time.`);
92 content = fileContent.value.toString();
93 hasRemoteChanged = true;
94 }
96 > const previewResult: IMergeResult = {
97 > content: hasConflicts ? lastSyncContent : content,
98 > localChange: hasLocalChanged ? fileContent ? Change.Modified : Change.Added : Change.None,
99 > remoteChange: hasRemoteChanged ? Change.Modified : Change.None,
100 > hasConflicts
101 > };
102 >
103 > const localContent = fileContent ? fileContent.value.toString() : null;
104 > return [{
105 > fileContent,
106 >
107 > baseResource: this.baseResource,
108 > baseContent: lastSyncContent,
109 >
110 > localResource: this.localResource,
111 > localContent,
112 > localChange: previewResult.localChange,
113 >
114 > remoteResource: this.remoteResource,
115 > remoteContent,
116 > remoteChange: previewResult.remoteChange,
117 >
118 > previewResource: this.previewResource,
119 > previewResult,
120 > acceptedResource: this.acceptedResource,
121 > }];
122 > }
123
124 protected async hasRemoteChanged(lastSyncUserData: IRemoteUserData): Promise<boolean> {
178
179 protected async applyResult(remoteUserData: IRemoteUserData, lastSyncUserData: IRemoteUserData | null, resourcePreviews: [IJsonResourcePreview, IAcceptResult][], force: boolean): Promise<void> {
180 > const { fileContent } = resourcePreviews[0][0]; abstractJsonSynchronizer.ts
181 > const { content, localChange, remoteChange } = resourcePreviews[0][1];
182 >
183 > if (localChange === Change.None && remoteChange === Change.None) {
184 this.logService.info(`${this.syncResourceLogLabel}: No changes found during synchronizing ${this.syncResource.syncResource}.`);
185 }
187 > if (localChange !== Change.None) {
188 this.logService.trace(`${this.syncResourceLogLabel}: Updating local ${this.syncResource.syncResource}...`);
189 if (fileContent) {
197 this.logService.info(`${this.syncResourceLogLabel}: Updated local ${this.syncResource.syncResource}`);
198 }
200 > if (remoteChange !== Change.None) {
201 this.logService.trace(`${this.syncResourceLogLabel}: Updating remote ${this.syncResource.syncResource}...`);
202 const remoteContents = JSON.stringify(this.toSyncContent(content));
210 } catch (e) { /* ignore */ }
211
212 > if (lastSyncUserData?.ref !== remoteUserData.ref) { abstractJsonSynchronizer.ts
213 this.logService.trace(`${this.syncResourceLogLabel}: Updating last synchronized ${this.syncResource.syncResource}...`);
214 await this.updateLastSyncUserData(remoteUserData);
215 this.logService.info(`${this.syncResourceLogLabel}: Updated last synchronized ${this.syncResource.syncResource}`);
216 }
218
219 async hasLocalData(): Promise<boolean> {