@@ -225,6 +225,14 @@ export class UserDataSyncService extends Disposable implements IUserDataSyncServ
225
225
const profileSynchronizer = this . getOrCreateActiveProfileSynchronizer ( profile , syncProfile ) ;
226
226
this . _syncErrors . push ( ...await this . syncProfile ( profileSynchronizer , manifest , merge , executionId , token ) ) ;
227
227
}
228
+ // Dispose & Delete profile synchronizers which do not exist anymore
229
+ for ( const [ key , profileSynchronizerItem ] of this . activeProfileSynchronizers . entries ( ) ) {
230
+ if ( this . userDataProfilesService . profiles . some ( p => p . id === profileSynchronizerItem [ 0 ] . profile . id ) ) {
231
+ continue ;
232
+ }
233
+ profileSynchronizerItem [ 1 ] . dispose ( ) ;
234
+ this . activeProfileSynchronizers . delete ( key ) ;
235
+ }
228
236
}
229
237
230
238
private async applyManualSync ( manifest : IUserDataManifest | null , executionId : string , token : CancellationToken ) : Promise < void > {
@@ -472,6 +480,12 @@ export class UserDataSyncService extends Disposable implements IUserDataSyncServ
472
480
473
481
getOrCreateActiveProfileSynchronizer ( profile : IUserDataProfile , syncProfile : ISyncUserDataProfile | undefined ) : ProfileSynchronizer {
474
482
let activeProfileSynchronizer = this . activeProfileSynchronizers . get ( profile . id ) ;
483
+ if ( activeProfileSynchronizer && activeProfileSynchronizer [ 0 ] . collection !== syncProfile ?. collection ) {
484
+ this . logService . error ( 'Profile synchronizer collection does not match with the remote sync profile collection' ) ;
485
+ activeProfileSynchronizer [ 1 ] . dispose ( ) ;
486
+ activeProfileSynchronizer = undefined ;
487
+ this . activeProfileSynchronizers . delete ( profile . id ) ;
488
+ }
475
489
if ( ! activeProfileSynchronizer ) {
476
490
const disposables = new DisposableStore ( ) ;
477
491
const profileSynchronizer = disposables . add ( this . instantiationService . createInstance ( ProfileSynchronizer , profile , syncProfile ?. collection ) ) ;
@@ -525,11 +539,9 @@ class ProfileSynchronizer extends Disposable {
525
539
private _onDidChangeConflicts = this . _register ( new Emitter < IUserDataSyncResourceConflicts [ ] > ( ) ) ;
526
540
readonly onDidChangeConflicts = this . _onDidChangeConflicts . event ;
527
541
528
- get profile ( ) : IUserDataProfile { return this . _profile ; }
529
-
530
542
constructor (
531
- private _profile : IUserDataProfile ,
532
- private readonly collection : string | undefined ,
543
+ readonly profile : IUserDataProfile ,
544
+ readonly collection : string | undefined ,
533
545
@IUserDataSyncEnablementService private readonly userDataSyncEnablementService : IUserDataSyncEnablementService ,
534
546
@IInstantiationService private readonly instantiationService : IInstantiationService ,
535
547
@IExtensionGalleryService private readonly extensionGalleryService : IExtensionGalleryService ,
@@ -568,7 +580,7 @@ class ProfileSynchronizer extends Disposable {
568
580
return ;
569
581
}
570
582
if ( syncResource === SyncResource . Profiles ) {
571
- if ( ! this . _profile . isDefault ) {
583
+ if ( ! this . profile . isDefault ) {
572
584
return ;
573
585
}
574
586
if ( ! this . userDataProfilesService . isEnabled ( ) ) {
@@ -608,13 +620,13 @@ class ProfileSynchronizer extends Disposable {
608
620
609
621
createSynchronizer ( syncResource : SyncResource ) : IUserDataSynchroniser & IDisposable {
610
622
switch ( syncResource ) {
611
- case SyncResource . Settings : return this . instantiationService . createInstance ( SettingsSynchroniser , this . _profile , this . collection ) ;
612
- case SyncResource . Keybindings : return this . instantiationService . createInstance ( KeybindingsSynchroniser , this . _profile , this . collection ) ;
613
- case SyncResource . Snippets : return this . instantiationService . createInstance ( SnippetsSynchroniser , this . _profile , this . collection ) ;
614
- case SyncResource . Tasks : return this . instantiationService . createInstance ( TasksSynchroniser , this . _profile , this . collection ) ;
615
- case SyncResource . GlobalState : return this . instantiationService . createInstance ( GlobalStateSynchroniser , this . _profile , this . collection ) ;
616
- case SyncResource . Extensions : return this . instantiationService . createInstance ( ExtensionsSynchroniser , this . _profile , this . collection ) ;
617
- case SyncResource . Profiles : return this . instantiationService . createInstance ( UserDataProfilesManifestSynchroniser , this . _profile , this . collection ) ;
623
+ case SyncResource . Settings : return this . instantiationService . createInstance ( SettingsSynchroniser , this . profile , this . collection ) ;
624
+ case SyncResource . Keybindings : return this . instantiationService . createInstance ( KeybindingsSynchroniser , this . profile , this . collection ) ;
625
+ case SyncResource . Snippets : return this . instantiationService . createInstance ( SnippetsSynchroniser , this . profile , this . collection ) ;
626
+ case SyncResource . Tasks : return this . instantiationService . createInstance ( TasksSynchroniser , this . profile , this . collection ) ;
627
+ case SyncResource . GlobalState : return this . instantiationService . createInstance ( GlobalStateSynchroniser , this . profile , this . collection ) ;
628
+ case SyncResource . Extensions : return this . instantiationService . createInstance ( ExtensionsSynchroniser , this . profile , this . collection ) ;
629
+ case SyncResource . Profiles : return this . instantiationService . createInstance ( UserDataProfilesManifestSynchroniser , this . profile , this . collection ) ;
618
630
}
619
631
}
620
632
0 commit comments