userDataSyncMachines.ts ×8

Frontier kind: Code frontier

unlabeled · c_8f78879116c3

12 tests · 28921 LOC · 134 files · introduces 0 tests · 66 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
13 ranges66 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
5024 ranges28921 lines · 134 files · Browse complete extent
All tests (intent)
12 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.

2 files ranked by introduced lines: 66 introduced LOC across 13 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/platform/userDataSync/common/userDataSyncMachines.ts 40 introduced LOC · 8 ranges

Open complete file

66 }
67
68 > function getPlatformName(): string { userDataSyncMachines.ts
69 > if (isSafari) { return Safari; }
70 > if (isChrome) { return Chrome; }
71 > if (isEdge) { return Edge; }
72 > if (isFirefox) { return Firefox; }
73 > if (isAndroid) { return Android; }
74 > return PlatformToString(isWeb ? Platform.Web : platform);
75 > }
76
77 export class UserDataSyncMachinesService extends Disposable implements IUserDataSyncMachinesService {
107
108 async addCurrentMachine(manifest?: IUserDataManifest): Promise<void> {
109 > const currentMachineId = await this.currentMachineIdPromise; userDataSyncMachines.ts
110 > const machineData = await this.readMachinesData(manifest);
111 > if (!machineData.machines.some(({ id }) => id === currentMachineId)) {
112 > machineData.machines.push({ id: currentMachineId, name: this.computeCurrentMachineName(machineData.machines), platform: getPlatformName() });
113 > await this.writeMachinesData(machineData);
114 > }
115 > }
116
117 async removeCurrentMachine(manifest?: IUserDataManifest): Promise<void> {
150
151 private computeCurrentMachineName(machines: IMachineData[]): string {
152 > const previousName = this.storageService.get(currentMachineNameKey, StorageScope.APPLICATION); userDataSyncMachines.ts
153 > if (previousName) {
154 if (!machines.some(machine => machine.name === previousName)) {
155 return previousName;
157 this.storageService.remove(currentMachineNameKey, StorageScope.APPLICATION);
158 }
160 > const namePrefix = `${this.productService.embedderIdentifier ? `${this.productService.embedderIdentifier} - ` : ''}${getPlatformName()} (${this.productService.nameShort})`;
161 > const nameRegEx = new RegExp(`${escapeRegExpCharacters(namePrefix)}\\s#(\\d+)`);
162 > let nameIndex = 0;
163 > for (const machine of machines) {
164 const matches = nameRegEx.exec(machine.name);
165 const index = matches ? parseInt(matches[1]) : 0;
166 nameIndex = index > nameIndex ? index : nameIndex;
167 }
168 > return `${namePrefix} #${nameIndex + 1}`; userDataSyncMachines.ts
169 > }
170
171 private async readMachinesData(manifest?: IUserDataManifest): Promise<IMachinesData> {
179
180 private async writeMachinesData(machinesData: IMachinesData): Promise<void> {
181 > const content = JSON.stringify(machinesData); userDataSyncMachines.ts
182 > const ref = await this.userDataSyncStoreService.writeResource(UserDataSyncMachinesService.RESOURCE, content, this.userData?.ref || null);
183 > this.userData = { ref, content };
184 > this._onDidChange.fire();
185 > }
186
187 private async readUserData(manifest?: IUserDataManifest): Promise<IUserData> {
188 if (this.userData) {
190 > const latestRef = manifest && manifest.latest ? manifest.latest[UserDataSyncMachinesService.RESOURCE] : undefined;
191 >
192 > // Last time synced resource and latest resource on server are same
193 > if (this.userData.ref === latestRef) {
194 return this.userData;
195 }
197 > // There is no resource on server and last time it was synced with no resource
198 > if (latestRef === undefined && this.userData.content === null) {
199 > return this.userData;
200 > }
201 > }
202
203 return this.userDataSyncStoreService.readResource(UserDataSyncMachinesService.RESOURCE, this.userData);
src/vs/platform/userDataSync/common/userDataAutoSyncService.ts 26 introduced LOC · 5 ranges

Open complete file

220 this.logService.debug('[AutoSync] Sync Finished');
221 if (!error) {
222 > // Sync finished without errors userDataAutoSyncService.ts
223 > this.successiveFailures = 0;
224 > return;
225 > }
226
227 // Error while syncing
532 const startTime = new Date().getTime();
533 await this.syncTask.run();
534 > this.telemetryService.publicLog2<{ userDataAutoSyncService.ts
535 > duration: number;
536 > }, {
537 > owner: 'sandy081';
538 > comment: 'Report when running a sync operation';
539 > duration: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Time taken to run sync operation' };
540 > }>('settingsSync:sync', { duration: new Date().getTime() - startTime });
541 >
542 > // After syncing, get the manifest if it was not available before
543 > if (this.manifest === null) {
544 try {
545 this.manifest = await this.userDataSyncStoreService.manifest(null);
548 }
549 }
551 > // Update local session id
552 if (this.manifest && this.manifest.session !== sessionId) {
553 > this.storageService.store(sessionIdKey, this.manifest.session, StorageScope.APPLICATION, StorageTarget.MACHINE); userDataAutoSyncService.ts
554 > }
555 >
556 > // Return if cancellation is requested
557 > if (token.isCancellationRequested) {
558 return;
559 }
561 > // Add current machine
562 > if (!currentMachine) {
563 > await this.userDataSyncMachinesService.addCurrentMachine(this.manifest || undefined);
564 > }
565 }
566