@@ -109,7 +109,6 @@ export interface IUserDataProfilesService {
109
109
110
110
readonly onDidResetWorkspaces : Event < void > ;
111
111
112
- isEnabled ( ) : boolean ;
113
112
createNamedProfile ( name : string , options ?: IUserDataProfileOptions , workspaceIdentifier ?: IAnyWorkspaceIdentifier ) : Promise < IUserDataProfile > ;
114
113
createTransientProfile ( workspaceIdentifier ?: IAnyWorkspaceIdentifier ) : Promise < IUserDataProfile > ;
115
114
createProfile ( id : string , name : string , options ?: IUserDataProfileOptions , workspaceIdentifier ?: IAnyWorkspaceIdentifier ) : Promise < IUserDataProfile > ;
@@ -190,7 +189,6 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf
190
189
191
190
readonly _serviceBrand : undefined ;
192
191
193
- protected enabled : boolean = true ;
194
192
readonly profilesHome : URI ;
195
193
private readonly profilesCacheHome : URI ;
196
194
@@ -231,34 +229,21 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf
231
229
this . _profilesObject = undefined ;
232
230
}
233
231
234
- setEnablement ( enabled : boolean ) : void {
235
- if ( this . enabled !== enabled ) {
236
- this . _profilesObject = undefined ;
237
- this . enabled = enabled ;
238
- }
239
- }
240
-
241
- isEnabled ( ) : boolean {
242
- return this . enabled ;
243
- }
244
-
245
232
protected _profilesObject : UserDataProfilesObject | undefined ;
246
233
protected get profilesObject ( ) : UserDataProfilesObject {
247
234
if ( ! this . _profilesObject ) {
248
235
const defaultProfile = this . createDefaultProfile ( ) ;
249
236
const profiles : Array < Mutable < IUserDataProfile > > = [ defaultProfile ] ;
250
- if ( this . enabled ) {
251
- try {
252
- for ( const storedProfile of this . getStoredProfiles ( ) ) {
253
- if ( ! storedProfile . name || ! isString ( storedProfile . name ) || ! storedProfile . location ) {
254
- this . logService . warn ( 'Skipping the invalid stored profile' , storedProfile . location || storedProfile . name ) ;
255
- continue ;
256
- }
257
- profiles . push ( toUserDataProfile ( basename ( storedProfile . location ) , storedProfile . name , storedProfile . location , this . profilesCacheHome , { shortName : storedProfile . shortName , icon : storedProfile . icon , useDefaultFlags : storedProfile . useDefaultFlags } , defaultProfile ) ) ;
237
+ try {
238
+ for ( const storedProfile of this . getStoredProfiles ( ) ) {
239
+ if ( ! storedProfile . name || ! isString ( storedProfile . name ) || ! storedProfile . location ) {
240
+ this . logService . warn ( 'Skipping the invalid stored profile' , storedProfile . location || storedProfile . name ) ;
241
+ continue ;
258
242
}
259
- } catch ( error ) {
260
- this . logService . error ( error ) ;
243
+ profiles . push ( toUserDataProfile ( basename ( storedProfile . location ) , storedProfile . name , storedProfile . location , this . profilesCacheHome , { shortName : storedProfile . shortName , icon : storedProfile . icon , useDefaultFlags : storedProfile . useDefaultFlags } , defaultProfile ) ) ;
261
244
}
245
+ } catch ( error ) {
246
+ this . logService . error ( error ) ;
262
247
}
263
248
const emptyWindows = new Map < string , IUserDataProfile > ( ) ;
264
249
if ( profiles . length ) {
@@ -315,10 +300,6 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf
315
300
}
316
301
317
302
async createProfile ( id : string , name : string , options ?: IUserDataProfileOptions , workspaceIdentifier ?: IAnyWorkspaceIdentifier ) : Promise < IUserDataProfile > {
318
- if ( ! this . enabled ) {
319
- throw new Error ( `Profiles are disabled in the current environment.` ) ;
320
- }
321
-
322
303
const profile = await this . doCreateProfile ( id , name , options , workspaceIdentifier ) ;
323
304
324
305
return profile ;
@@ -369,10 +350,6 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf
369
350
}
370
351
371
352
async updateProfile ( profile : IUserDataProfile , options : IUserDataProfileUpdateOptions ) : Promise < IUserDataProfile > {
372
- if ( ! this . enabled ) {
373
- throw new Error ( `Profiles are disabled in the current environment.` ) ;
374
- }
375
-
376
353
const profilesToUpdate : IUserDataProfile [ ] = [ ] ;
377
354
for ( const existing of this . profiles ) {
378
355
let profileToUpdate : Mutable < IUserDataProfile > | undefined ;
@@ -423,9 +400,6 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf
423
400
}
424
401
425
402
async removeProfile ( profileToRemove : IUserDataProfile ) : Promise < void > {
426
- if ( ! this . enabled ) {
427
- throw new Error ( `Profiles are disabled in the current environment.` ) ;
428
- }
429
403
if ( profileToRemove . isDefault ) {
430
404
throw new Error ( 'Cannot remove default profile' ) ;
431
405
}
@@ -460,10 +434,6 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf
460
434
}
461
435
462
436
async setProfileForWorkspace ( workspaceIdentifier : IAnyWorkspaceIdentifier , profileToSet : IUserDataProfile ) : Promise < void > {
463
- if ( ! this . enabled ) {
464
- throw new Error ( `Profiles are disabled in the current environment.` ) ;
465
- }
466
-
467
437
const profile = this . profiles . find ( p => p . id === profileToSet . id ) ;
468
438
if ( ! profile ) {
469
439
throw new Error ( `Profile '${ profileToSet . name } ' does not exist` ) ;
@@ -483,10 +453,6 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf
483
453
}
484
454
485
455
unsetWorkspace ( workspaceIdentifier : IAnyWorkspaceIdentifier , transient : boolean = false ) : void {
486
- if ( ! this . enabled ) {
487
- throw new Error ( `Profiles are disabled in the current environment.` ) ;
488
- }
489
-
490
456
const workspace = this . getWorkspace ( workspaceIdentifier ) ;
491
457
if ( URI . isUri ( workspace ) ) {
492
458
const currentlyAssociatedProfile = this . getProfileForWorkspace ( workspaceIdentifier ) ;
@@ -510,9 +476,6 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf
510
476
}
511
477
512
478
async cleanUp ( ) : Promise < void > {
513
- if ( ! this . enabled ) {
514
- return ;
515
- }
516
479
if ( await this . fileService . exists ( this . profilesHome ) ) {
517
480
const stat = await this . fileService . resolve ( this . profilesHome ) ;
518
481
await Promise . all ( ( stat . children || [ ] )
@@ -522,9 +485,6 @@ export class UserDataProfilesService extends Disposable implements IUserDataProf
522
485
}
523
486
524
487
async cleanUpTransientProfiles ( ) : Promise < void > {
525
- if ( ! this . enabled ) {
526
- return ;
527
- }
528
488
const unAssociatedTransientProfiles = this . transientProfilesObject . profiles . filter ( p => ! this . isProfileAssociatedToWorkspace ( p ) ) ;
529
489
await Promise . allSettled ( unAssociatedTransientProfiles . map ( p => this . removeProfile ( p ) ) ) ;
530
490
}
0 commit comments