@@ -14,7 +14,7 @@ import { FormattingOptions } from 'vs/base/common/jsonFormatter';
14
14
import { Disposable } from 'vs/base/common/lifecycle' ;
15
15
import { IExtUri } from 'vs/base/common/resources' ;
16
16
import { uppercaseFirstLetter } from 'vs/base/common/strings' ;
17
- import { isString , isUndefined } from 'vs/base/common/types' ;
17
+ import { isUndefined } from 'vs/base/common/types' ;
18
18
import { URI } from 'vs/base/common/uri' ;
19
19
import { IHeaders } from 'vs/base/parts/request/common/request' ;
20
20
import { localize } from 'vs/nls' ;
@@ -26,7 +26,7 @@ import { getServiceMachineId } from 'vs/platform/externalServices/common/service
26
26
import { IStorageService } from 'vs/platform/storage/common/storage' ;
27
27
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry' ;
28
28
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity' ;
29
- import { Change , getLastSyncResourceUri , IRemoteUserData , IResourcePreview as IBaseResourcePreview , ISyncData , ISyncResourceHandle , IUserDataSyncResourcePreview as IBaseSyncResourcePreview , IUserData , IUserDataInitializer , IUserDataSyncBackupStoreService , IUserDataSyncConfiguration , IUserDataSynchroniser , IUserDataSyncLogService , IUserDataSyncEnablementService , IUserDataSyncStoreService , IUserDataSyncUtilService , MergeState , PREVIEW_DIR_NAME , SyncResource , SyncStatus , UserDataSyncError , UserDataSyncErrorCode , USER_DATA_SYNC_CONFIGURATION_SCOPE , USER_DATA_SYNC_SCHEME , IUserDataResourceManifest , getPathSegments , IUserDataSyncResourceConflicts , IUserDataSyncResource } from 'vs/platform/userDataSync/common/userDataSync' ;
29
+ import { Change , getLastSyncResourceUri , IRemoteUserData , IResourcePreview as IBaseResourcePreview , ISyncData , IUserDataSyncResourcePreview as IBaseSyncResourcePreview , IUserData , IUserDataInitializer , IUserDataSyncBackupStoreService , IUserDataSyncConfiguration , IUserDataSynchroniser , IUserDataSyncLogService , IUserDataSyncEnablementService , IUserDataSyncStoreService , IUserDataSyncUtilService , MergeState , PREVIEW_DIR_NAME , SyncResource , SyncStatus , UserDataSyncError , UserDataSyncErrorCode , USER_DATA_SYNC_CONFIGURATION_SCOPE , USER_DATA_SYNC_SCHEME , IUserDataResourceManifest , getPathSegments , IUserDataSyncResourceConflicts , IUserDataSyncResource } from 'vs/platform/userDataSync/common/userDataSync' ;
30
30
import { IUserDataProfile , IUserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile' ;
31
31
32
32
type IncompatibleSyncSourceClassification = {
@@ -242,12 +242,7 @@ export abstract class AbstractSynchroniser extends Disposable implements IUserDa
242
242
}
243
243
}
244
244
245
- async replace ( uri : URI ) : Promise < boolean > {
246
- const content = await this . resolveContent ( uri ) ;
247
- if ( ! content ) {
248
- return false ;
249
- }
250
-
245
+ async replace ( content : string ) : Promise < boolean > {
251
246
const syncData = this . parseSyncData ( content ) ;
252
247
if ( ! syncData ) {
253
248
return false ;
@@ -490,48 +485,6 @@ export abstract class AbstractSynchroniser extends Disposable implements IUserDa
490
485
return ! ! lastSyncData && lastSyncData . syncData !== null /* `null` sync data implies resource is not synced */ ;
491
486
}
492
487
493
- async getRemoteSyncResourceHandles ( ) : Promise < ISyncResourceHandle [ ] > {
494
- const handles = await this . userDataSyncStoreService . getAllResourceRefs ( this . resource , this . collection ) ;
495
- return handles . map ( ( { created, ref } ) => ( { created, uri : this . toRemoteBackupResource ( ref ) } ) ) ;
496
- }
497
-
498
- async getLocalSyncResourceHandles ( ) : Promise < ISyncResourceHandle [ ] > {
499
- const handles = await this . userDataSyncBackupStoreService . getAllRefs ( this . syncResource . profile , this . resource ) ;
500
- return handles . map ( ( { created, ref } ) => ( { created, uri : this . toLocalBackupResource ( ref ) } ) ) ;
501
- }
502
-
503
- private toRemoteBackupResource ( ref : string ) : URI {
504
- return URI . from ( { scheme : USER_DATA_SYNC_SCHEME , authority : 'remote-backup' , path : `/${ this . syncResource . profile . isDefault ? '' : `${ this . syncResource . profile . id } /` } ${ this . resource } /${ ref } ` } ) ;
505
- }
506
-
507
- private toLocalBackupResource ( ref : string ) : URI {
508
- return URI . from ( { scheme : USER_DATA_SYNC_SCHEME , authority : 'local-backup' , path : `/${ this . syncResource . profile . id } /${ this . resource } /${ ref } ` } ) ;
509
- }
510
-
511
- async getMachineId ( { uri } : ISyncResourceHandle ) : Promise < string | undefined > {
512
- const ref = this . extUri . basename ( uri ) ;
513
- if ( this . extUri . isEqual ( uri , this . toRemoteBackupResource ( ref ) ) ) {
514
- const { content } = await this . getUserData ( ref ) ;
515
- if ( content ) {
516
- const syncData = this . parseSyncData ( content ) ;
517
- return syncData ?. machineId ;
518
- }
519
- }
520
- return undefined ;
521
- }
522
-
523
- async resolveContent ( uri : URI ) : Promise < string | null > {
524
- const ref = this . extUri . basename ( uri ) ;
525
- if ( this . extUri . isEqual ( uri , this . toRemoteBackupResource ( ref ) ) ) {
526
- const { content } = await this . getUserData ( ref ) ;
527
- return content ;
528
- }
529
- if ( this . extUri . isEqual ( uri , this . toLocalBackupResource ( ref ) ) ) {
530
- return this . userDataSyncBackupStoreService . resolveContent ( this . syncResource . profile , this . resource , ref ) ;
531
- }
532
- return null ;
533
- }
534
-
535
488
protected async resolvePreviewContent ( uri : URI ) : Promise < string | null > {
536
489
const syncPreview = this . syncPreviewPromise ? await this . syncPreviewPromise : null ;
537
490
if ( syncPreview ) {
@@ -670,14 +623,9 @@ export abstract class AbstractSynchroniser extends Disposable implements IUserDa
670
623
throw new UserDataSyncError ( localize ( 'incompatible sync data' , "Cannot parse sync data as it is not compatible with the current version." ) , UserDataSyncErrorCode . IncompatibleRemoteContent , this . resource ) ;
671
624
}
672
625
673
- private async getUserData ( refOrLastSyncData : string | IRemoteUserData | null ) : Promise < IUserData > {
674
- if ( isString ( refOrLastSyncData ) ) {
675
- const content = await this . userDataSyncStoreService . resolveResourceContent ( this . resource , refOrLastSyncData , this . collection ) ;
676
- return { ref : refOrLastSyncData , content } ;
677
- } else {
678
- const lastSyncUserData : IUserData | null = refOrLastSyncData ? { ref : refOrLastSyncData . ref , content : refOrLastSyncData . syncData ? JSON . stringify ( refOrLastSyncData . syncData ) : null } : null ;
679
- return this . userDataSyncStoreService . readResource ( this . resource , lastSyncUserData , this . collection , this . syncHeaders ) ;
680
- }
626
+ private async getUserData ( lastSyncData : IRemoteUserData | null ) : Promise < IUserData > {
627
+ const lastSyncUserData : IUserData | null = lastSyncData ? { ref : lastSyncData . ref , content : lastSyncData . syncData ? JSON . stringify ( lastSyncData . syncData ) : null } : null ;
628
+ return this . userDataSyncStoreService . readResource ( this . resource , lastSyncUserData , this . collection , this . syncHeaders ) ;
681
629
}
682
630
683
631
protected async updateRemoteUserData ( content : string , ref : string | null ) : Promise < IRemoteUserData > {
@@ -729,7 +677,7 @@ export abstract class AbstractSynchroniser extends Disposable implements IUserDa
729
677
protected abstract hasRemoteChanged ( lastSyncUserData : IRemoteUserData ) : Promise < boolean > ;
730
678
731
679
abstract hasLocalData ( ) : Promise < boolean > ;
732
- abstract getAssociatedResources ( syncResourceHandle : ISyncResourceHandle ) : Promise < { resource : URI ; comparableResource : URI } [ ] > ;
680
+ abstract resolveContent ( uri : URI ) : Promise < string | null > ;
733
681
}
734
682
735
683
export interface IFileResourcePreview extends IResourcePreview {
0 commit comments