Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/vscode.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSandeep Somavarapu <sasomava@microsoft.com>2022-11-11 03:57:23 +0300
committerGitHub <noreply@github.com>2022-11-11 03:57:23 +0300
commit0749cc677c139706852325a23f7f2e9fcc33f40a (patch)
tree1655c357a8df00a84c97bce3e073e9248ecb8e65
parent1ccc8d438b3a230ea47abe896a0ace8e19a93a6d (diff)
fix profiles enablement in web (#166059)
- only configurable in stable (not remote) - do not sync if disabled
-rw-r--r--src/vs/platform/userDataProfile/browser/userDataProfile.ts8
-rw-r--r--src/vs/platform/userDataSync/common/userDataProfilesManifestSync.ts5
-rw-r--r--src/vs/workbench/browser/web.main.ts30
3 files changed, 29 insertions, 14 deletions
diff --git a/src/vs/platform/userDataProfile/browser/userDataProfile.ts b/src/vs/platform/userDataProfile/browser/userDataProfile.ts
index a3144510cf6..918be5652af 100644
--- a/src/vs/platform/userDataProfile/browser/userDataProfile.ts
+++ b/src/vs/platform/userDataProfile/browser/userDataProfile.ts
@@ -10,7 +10,7 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
import { IFileService } from 'vs/platform/files/common/files';
import { ILogService } from 'vs/platform/log/common/log';
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity';
-import { DidChangeProfilesEvent, IUserDataProfile, IUserDataProfilesService, PROFILES_ENABLEMENT_CONFIG, reviveProfile, StoredProfileAssociations, StoredUserDataProfile, UserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile';
+import { DidChangeProfilesEvent, IUserDataProfile, IUserDataProfilesService, reviveProfile, StoredProfileAssociations, StoredUserDataProfile, UserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile';
type BroadcastedProfileChanges = UriDto<Omit<DidChangeProfilesEvent, 'all'>>;
@@ -25,7 +25,6 @@ export class BrowserUserDataProfilesService extends UserDataProfilesService impl
@ILogService logService: ILogService,
) {
super(environmentService, fileService, uriIdentityService, logService);
- super.setEnablement(window.localStorage.getItem(PROFILES_ENABLEMENT_CONFIG) === 'true');
this.changesBroadcastChannel = this._register(new BroadcastDataChannel<BroadcastedProfileChanges>(`${UserDataProfilesService.PROFILES_KEY}.changes`));
this._register(this.changesBroadcastChannel.onDidReceiveData(changes => {
try {
@@ -66,11 +65,6 @@ export class BrowserUserDataProfilesService extends UserDataProfilesService impl
}
}
- override setEnablement(enabled: boolean): void {
- super.setEnablement(enabled);
- window.localStorage.setItem(PROFILES_ENABLEMENT_CONFIG, enabled ? 'true' : 'false');
- }
-
protected override getStoredProfiles(): StoredUserDataProfile[] {
try {
const value = window.localStorage.getItem(UserDataProfilesService.PROFILES_KEY);
diff --git a/src/vs/platform/userDataSync/common/userDataProfilesManifestSync.ts b/src/vs/platform/userDataSync/common/userDataProfilesManifestSync.ts
index 8be70621bfd..6336caec042 100644
--- a/src/vs/platform/userDataSync/common/userDataProfilesManifestSync.ts
+++ b/src/vs/platform/userDataSync/common/userDataProfilesManifestSync.ts
@@ -15,7 +15,7 @@ import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity'
import { IUserDataProfile, IUserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile';
import { AbstractSynchroniser, IAcceptResult, IMergeResult, IResourcePreview } from 'vs/platform/userDataSync/common/abstractSynchronizer';
import { merge } from 'vs/platform/userDataSync/common/userDataProfilesManifestMerge';
-import { Change, IRemoteUserData, IUserDataSyncBackupStoreService, IUserDataSynchroniser, IUserDataSyncLogService, IUserDataSyncEnablementService, IUserDataSyncStoreService, SyncResource, USER_DATA_SYNC_SCHEME, ISyncUserDataProfile, ISyncData, IUserDataResourceManifest } from 'vs/platform/userDataSync/common/userDataSync';
+import { Change, IRemoteUserData, IUserDataSyncBackupStoreService, IUserDataSynchroniser, IUserDataSyncLogService, IUserDataSyncEnablementService, IUserDataSyncStoreService, SyncResource, USER_DATA_SYNC_SCHEME, ISyncUserDataProfile, ISyncData, IUserDataResourceManifest, UserDataSyncError, UserDataSyncErrorCode } from 'vs/platform/userDataSync/common/userDataSync';
export interface IUserDataProfileManifestResourceMergeResult extends IAcceptResult {
readonly local: { added: ISyncUserDataProfile[]; removed: IUserDataProfile[]; updated: ISyncUserDataProfile[] };
@@ -66,6 +66,9 @@ export class UserDataProfilesManifestSynchroniser extends AbstractSynchroniser i
}
protected async generateSyncPreview(remoteUserData: IRemoteUserData, lastSyncUserData: IRemoteUserData | null, isRemoteDataFromCurrentMachine: boolean): Promise<IUserDataProfilesManifestResourcePreview[]> {
+ if (!this.userDataProfilesService.isEnabled()) {
+ throw new UserDataSyncError('Cannot sync profiles because they are disabled', UserDataSyncErrorCode.LocalError);
+ }
const remoteProfiles: ISyncUserDataProfile[] | null = remoteUserData.syncData ? parseUserDataProfilesManifest(remoteUserData.syncData) : null;
const lastSyncProfiles: ISyncUserDataProfile[] | null = lastSyncUserData?.syncData ? parseUserDataProfilesManifest(lastSyncUserData.syncData) : null;
const localProfiles = this.getLocalUserDataProfiles();
diff --git a/src/vs/workbench/browser/web.main.ts b/src/vs/workbench/browser/web.main.ts
index 2e31824717d..0053149f6c9 100644
--- a/src/vs/workbench/browser/web.main.ts
+++ b/src/vs/workbench/browser/web.main.ts
@@ -82,6 +82,7 @@ import { UserDataProfileService } from 'vs/workbench/services/userDataProfile/co
import { IUserDataProfileService } from 'vs/workbench/services/userDataProfile/common/userDataProfile';
import { BrowserUserDataProfilesService } from 'vs/platform/userDataProfile/browser/userDataProfile';
import { timeout } from 'vs/base/common/async';
+import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
export class BrowserMain extends Disposable {
@@ -288,6 +289,21 @@ export class BrowserMain extends Disposable {
const userDataProfileService = new UserDataProfileService(currentProfile, userDataProfilesService);
serviceCollection.set(IUserDataProfileService, userDataProfileService);
+ let isProfilesEnablementConfigured = false;
+ if (environmentService.remoteAuthority) {
+ // Always Disabled in web with remote connection
+ userDataProfilesService.setEnablement(false);
+ } else {
+ if (productService.quality === 'stable') {
+ // Enabled from Config
+ userDataProfilesService.setEnablement(window.localStorage.getItem(PROFILES_ENABLEMENT_CONFIG) === 'true');
+ isProfilesEnablementConfigured = true;
+ } else {
+ // Always Enabled
+ userDataProfilesService.setEnablement(true);
+ }
+ }
+
// Long running services (workspace, config, storage)
const [configurationService, storageService] = await Promise.all([
this.createWorkspaceService(workspace, environmentService, userDataProfileService, userDataProfilesService, fileService, remoteAgentService, uriIdentityService, logService).then(service => {
@@ -310,12 +326,14 @@ export class BrowserMain extends Disposable {
})
]);
- userDataProfilesService.setEnablement(!environmentService.remoteAuthority && (productService.quality !== 'stable' || configurationService.getValue(PROFILES_ENABLEMENT_CONFIG)));
- this._register(configurationService.onDidChangeConfiguration(e => {
- if (e.affectsConfiguration(PROFILES_ENABLEMENT_CONFIG)) {
- userDataProfilesService.setEnablement(!!configurationService.getValue(PROFILES_ENABLEMENT_CONFIG));
- }
- }));
+ if (isProfilesEnablementConfigured) {
+ userDataProfilesService.setEnablement(!!configurationService.getValue(PROFILES_ENABLEMENT_CONFIG));
+ this._register(configurationService.onDidChangeConfiguration(e => {
+ if (e.source !== ConfigurationTarget.DEFAULT && e.affectsConfiguration(PROFILES_ENABLEMENT_CONFIG)) {
+ window.localStorage.setItem(PROFILES_ENABLEMENT_CONFIG, !!configurationService.getValue(PROFILES_ENABLEMENT_CONFIG) ? 'true' : 'false');
+ }
+ }));
+ }
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//