src/vs/platform/userDataSync/common/userDataProfilesManifestSync.ts/UserDataProfilesManifestSynchroniser/applyResult
class UserDataProfilesManifestSynchroniser:	protected async applyResult(remoteUserData: IRemoteUserData, lastSyncUserData: IRemoteUserData | null, resourcePreviews: [IUserDataProfilesManifestResourcePreview, IUserDataProfileManifestResourceMergeResult][], force: boolean): Promise<void> {
		const { local, remote, localChange, remoteChange } = resourcePreviews[0][1];
		if (localChange === Change.None && remoteChange === Change.None) {
			this.logService.info(`${this.syncResourceLogLabel}: No changes found during synchronizing profiles.`);
		}

		if (localChange !== Change.None) {
			await this.backupLocal(stringifyLocalProfiles(this.getLocalUserDataProfiles(), false));
			const promises: Promise<any>[] = [];
			for (const profile of local.added) {
				promises.push((async () => {
					this.logService.trace(`${this.syncResourceLogLabel}: Creating '${profile.name}' profile...`);
					await this.userDataProfilesService.createProfile(profile.id, profile.name, { shortName: profile.shortName });
					this.logService.info(`${this.syncResourceLogLabel}: Created profile '${profile.name}'.`);
				})());
			}
			for (const profile of local.removed) {
				promises.push((async () => {
					this.logService.trace(`${this.syncResourceLogLabel}: Removing '${profile.name}' profile...`);
					await this.userDataProfilesService.removeProfile(profile);
					this.logService.info(`${this.syncResourceLogLabel}: Removed profile '${profile.name}'.`);
				})());
			}
			for (const profile of local.updated) {
				const localProfile = this.userDataProfilesService.profiles.find(p => p.id === profile.id);
				if (localProfile) {
					promises.push((async () => {
						this.logService.trace(`${this.syncResourceLogLabel}: Updating '${profile.name}' profile...`);
						await this.userDataProfilesService.updateProfile(localProfile, { name: profile.name, shortName: profile.shortName });
						this.logService.info(`${this.syncResourceLogLabel}: Updated profile '${profile.name}'.`);
					})());
				} else {
					this.logService.info(`${this.syncResourceLogLabel}: Could not find profile with id '${profile.id}' to update.`);
				}
			}
			await Promise.all(promises);
		}

		if (remoteChange !== Change.None) {
			const remoteProfiles = resourcePreviews[0][0].remoteProfiles || [];
			this.logService.trace(`${this.syncResourceLogLabel}: Updating remote profiles...`);
			for (const profile of remote?.added || []) {
				const collection = await this.userDataSyncStoreService.createCollection(this.syncHeaders);
				remoteProfiles.push({ id: profile.id, name: profile.name, collection, shortName: profile.shortName });
			}
			for (const profile of remote?.removed || []) {
				remoteProfiles.splice(remoteProfiles.findIndex(({ id }) => profile.id === id), 1);
			}
			for (const profile of remote?.updated || []) {
				const profileToBeUpdated = remoteProfiles.find(({ id }) => profile.id === id);
				if (profileToBeUpdated) {
					remoteProfiles.splice(remoteProfiles.indexOf(profileToBeUpdated), 1, { id: profile.id, name: profile.name, collection: profileToBeUpdated.collection, shortName: profile.shortName });
				}
			}
			remoteUserData = await this.updateRemoteUserData(this.stringifyRemoteProfiles(remoteProfiles), force ? null : remoteUserData.ref);
			this.logService.info(`${this.syncResourceLogLabel}: Updated remote profiles.${remote?.added.length ? ` Added: ${JSON.stringify(remote.added.map(e => e.name))}.` : ''}${remote?.updated.length ? ` Updated: ${JSON.stringify(remote.updated.map(e => e.name))}.` : ''}${remote?.removed.length ? ` Removed: ${JSON.stringify(remote.removed.map(e => e.name))}.` : ''}`);

			for (const profile of remote?.removed || []) {
				await this.userDataSyncStoreService.deleteCollection(profile.collection, this.syncHeaders);
			}
		}

		if (lastSyncUserData?.ref !== remoteUserData.ref) {
			// update last sync
			this.logService.trace(`${this.syncResourceLogLabel}: Updating last synchronized profiles...`);
			await this.updateLastSyncUserData(remoteUserData);
			this.logService.info(`${this.syncResourceLogLabel}: Updated last synchronized profiles.`);
		}
	}