@@ -17,13 +17,14 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'
1717import { ILogService } from 'vs/platform/log/common/log' ;
1818import { IUserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile' ;
1919import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity' ;
20- import { Mutable , isObject , isString } from 'vs/base/common/types' ;
20+ import { Mutable , isObject , isString , isUndefined } from 'vs/base/common/types' ;
2121import { getErrorMessage } from 'vs/base/common/errors' ;
2222import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry' ;
2323
2424interface IStoredProfileExtension {
2525 identifier : IExtensionIdentifier ;
2626 location : UriComponents | string ;
27+ relativeLocation : string | undefined ;
2728 version : string ;
2829 metadata ?: Metadata ;
2930}
@@ -247,14 +248,23 @@ export abstract class AbstractExtensionsProfileScannerService extends Disposable
247248 this . reportAndThrowInvalidConentError ( file ) ;
248249 }
249250 let location : URI ;
250- if ( isString ( e . location ) ) {
251+ if ( isString ( e . relativeLocation ) ) {
252+ // Extension in new format. No migration needed.
253+ location = this . resolveExtensionLocation ( e . relativeLocation ) ;
254+ } else if ( isString ( e . location ) ) {
255+ // Extension in intermediate format. Migrate to new format.
251256 location = this . resolveExtensionLocation ( e . location ) ;
257+ migrate = true ;
258+ e . relativeLocation = e . location ;
259+ // retain old format so that old clients can read it
260+ e . location = location . toJSON ( ) ;
252261 } else {
253262 location = URI . revive ( e . location ) ;
254263 const relativePath = this . toRelativePath ( location ) ;
255264 if ( relativePath ) {
265+ // Extension in old format. Migrate to new format.
256266 migrate = true ;
257- e . location = relativePath ;
267+ e . relativeLocation = relativePath ;
258268 }
259269 }
260270 extensions . push ( {
@@ -275,7 +285,9 @@ export abstract class AbstractExtensionsProfileScannerService extends Disposable
275285 const storedProfileExtensions : IStoredProfileExtension [ ] = extensions . map ( e => ( {
276286 identifier : e . identifier ,
277287 version : e . version ,
278- location : this . toRelativePath ( e . location ) ?? e . location . toJSON ( ) ,
288+ // retain old format so that old clients can read it
289+ location : e . location . toJSON ( ) ,
290+ relativeLocation : this . toRelativePath ( e . location ) ,
279291 metadata : e . metadata
280292 } ) ) ;
281293 await this . fileService . writeFile ( file , VSBuffer . fromString ( JSON . stringify ( storedProfileExtensions ) ) ) ;
@@ -376,6 +388,7 @@ function isStoredProfileExtension(candidate: any): candidate is IStoredProfileEx
376388 return isObject ( candidate )
377389 && isIExtensionIdentifier ( candidate . identifier )
378390 && ( isUriComponents ( candidate . location ) || isString ( candidate . location ) )
391+ && ( isUndefined ( candidate . relativeLocation ) || isString ( candidate . relativeLocation ) )
379392 && candidate . version && isString ( candidate . version ) ;
380393}
381394
0 commit comments