@@ -21,7 +21,7 @@ import {
2121 INSTALL_ERROR_MALICIOUS ,
2222 INSTALL_ERROR_INCOMPATIBLE
2323} from 'vs/platform/extensionManagement/common/extensionManagement' ;
24- import { getGalleryExtensionIdFromLocal , adoptToGalleryExtensionId , areSameExtensions , getGalleryExtensionId , groupByExtension , getMaliciousExtensionsSet , getLocalExtensionId , getGalleryExtensionTelemetryData , getLocalExtensionTelemetryData , getIdFromLocalExtensionId , getLocalExtensionIdFromManifest , getLocalExtensionIdFromGallery } from 'vs/platform/extensionManagement/common/extensionManagementUtil' ;
24+ import { adoptToGalleryExtensionId , areSameExtensions , getGalleryExtensionId , groupByExtension , getMaliciousExtensionsSet , getLocalExtensionId , getGalleryExtensionTelemetryData , getLocalExtensionTelemetryData , getIdFromLocalExtensionId , getLocalExtensionIdFromManifest , getLocalExtensionIdFromGallery } from 'vs/platform/extensionManagement/common/extensionManagementUtil' ;
2525import { localizeManifest } from '../common/extensionNls' ;
2626import { IEnvironmentService } from 'vs/platform/environment/common/environment' ;
2727import { Limiter , always , createCancelablePromise , CancelablePromise , Queue } from 'vs/base/common/async' ;
@@ -150,7 +150,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
150150 }
151151
152152 zip ( extension : ILocalExtension ) : Promise < URI > {
153- this . logService . trace ( 'ExtensionManagementService#zip' , extension . identifier . id ) ;
153+ this . logService . trace ( 'ExtensionManagementService#zip' , extension . galleryIdentifier . id ) ;
154154 return this . collectFiles ( extension )
155155 . then ( files => zip ( path . join ( tmpdir ( ) , generateUuid ( ) ) , files ) )
156156 . then ( path => URI . file ( path ) ) ;
@@ -204,7 +204,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
204204 const extensionIdentifier = { id : getGalleryExtensionId ( manifest . publisher , manifest . name ) } ;
205205 return this . getInstalled ( ExtensionType . User )
206206 . then ( installedExtensions => {
207- const newer = installedExtensions . filter ( local => areSameExtensions ( extensionIdentifier , { id : getGalleryExtensionIdFromLocal ( local ) } ) && semver . gt ( local . manifest . version , manifest . version ) ) [ 0 ] ;
207+ const newer = installedExtensions . filter ( local => areSameExtensions ( extensionIdentifier , local . galleryIdentifier ) && semver . gt ( local . manifest . version , manifest . version ) ) [ 0 ] ;
208208 return newer ? this . uninstall ( newer , true ) : undefined ;
209209 } )
210210 . then ( ( ) => {
@@ -349,7 +349,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
349349 }
350350
351351 reinstallFromGallery ( extension : ILocalExtension ) : Promise < void > {
352- this . logService . trace ( 'ExtensionManagementService#reinstallFromGallery' , extension . identifier . id ) ;
352+ this . logService . trace ( 'ExtensionManagementService#reinstallFromGallery' , extension . galleryIdentifier . id ) ;
353353 if ( ! this . galleryService . isEnabled ( ) ) {
354354 return Promise . reject ( new Error ( nls . localize ( 'MarketPlaceDisabled' , "Marketplace is not enabled" ) ) ) ;
355355 }
@@ -367,7 +367,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
367367 }
368368
369369 private getOperation ( extensionToInstall : IExtensionIdentifier , installed : ILocalExtension [ ] ) : InstallOperation {
370- return installed . some ( i => areSameExtensions ( { id : getGalleryExtensionIdFromLocal ( i ) , uuid : i . identifier . uuid } , extensionToInstall ) ) ? InstallOperation . Update : InstallOperation . Install ;
370+ return installed . some ( i => areSameExtensions ( i . galleryIdentifier , extensionToInstall ) ) ? InstallOperation . Update : InstallOperation . Install ;
371371 }
372372
373373 private getTelemetryEvent ( operation : InstallOperation ) : string {
@@ -530,7 +530,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
530530 }
531531
532532 uninstall ( extension : ILocalExtension , force = false ) : Promise < void > {
533- this . logService . trace ( 'ExtensionManagementService#uninstall' , extension . identifier . id ) ;
533+ this . logService . trace ( 'ExtensionManagementService#uninstall' , extension . galleryIdentifier . id ) ;
534534 return this . toNonCancellablePromise ( this . getInstalled ( ExtensionType . User )
535535 . then ( installed => {
536536 const extensionsToUninstall = installed
@@ -545,7 +545,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
545545 }
546546
547547 updateMetadata ( local : ILocalExtension , metadata : IGalleryMetadata ) : Promise < ILocalExtension > {
548- this . logService . trace ( 'ExtensionManagementService#updateMetadata' , local . identifier . id ) ;
548+ this . logService . trace ( 'ExtensionManagementService#updateMetadata' , local . galleryIdentifier . id ) ;
549549 local . metadata = metadata ;
550550 return this . saveMetadataForLocalExtension ( local )
551551 . then ( localExtension => {
@@ -572,11 +572,11 @@ export class ExtensionManagementService extends Disposable implements IExtension
572572 }
573573
574574 private findGalleryExtension ( local : ILocalExtension ) : Promise < IGalleryExtension > {
575- if ( local . identifier . uuid ) {
576- return this . findGalleryExtensionById ( local . identifier . uuid )
577- . then ( galleryExtension => galleryExtension ? galleryExtension : this . findGalleryExtensionByName ( getGalleryExtensionIdFromLocal ( local ) ) ) ;
575+ if ( local . galleryIdentifier . uuid ) {
576+ return this . findGalleryExtensionById ( local . galleryIdentifier . uuid )
577+ . then ( galleryExtension => galleryExtension ? galleryExtension : this . findGalleryExtensionByName ( local . galleryIdentifier . id ) ) ;
578578 }
579- return this . findGalleryExtensionByName ( getGalleryExtensionIdFromLocal ( local ) ) ;
579+ return this . findGalleryExtensionByName ( local . galleryIdentifier . id ) ;
580580 }
581581
582582 private findGalleryExtensionById ( uuid : string ) : Promise < IGalleryExtension > {
@@ -672,31 +672,30 @@ export class ExtensionManagementService extends Disposable implements IExtension
672672 return Promise . resolve ( pfs . exists ( extension . location . fsPath ) )
673673 . then ( exists => exists ? null : Promise . reject ( new Error ( nls . localize ( 'notExists' , "Could not find extension" ) ) ) )
674674 . then ( ( ) => {
675- this . logService . info ( 'Uninstalling extension:' , extension . identifier . id ) ;
675+ this . logService . info ( 'Uninstalling extension:' , extension . galleryIdentifier . id ) ;
676676 this . _onUninstallExtension . fire ( extension . identifier ) ;
677677 } ) ;
678678 }
679679
680680 private uninstallExtension ( local : ILocalExtension ) : Promise < void > {
681- const id = getGalleryExtensionIdFromLocal ( local ) ;
682- let promise = this . uninstallingExtensions . get ( id ) ;
681+ let promise = this . uninstallingExtensions . get ( local . galleryIdentifier . id ) ;
683682 if ( ! promise ) {
684683 // Set all versions of the extension as uninstalled
685684 promise = createCancelablePromise ( token => this . scanUserExtensions ( false )
686- . then ( userExtensions => this . setUninstalled ( ...userExtensions . filter ( u => areSameExtensions ( { id : getGalleryExtensionIdFromLocal ( u ) , uuid : u . identifier . uuid } , { id , uuid : local . identifier . uuid } ) ) ) )
687- . then ( ( ) => { this . uninstallingExtensions . delete ( id ) ; } ) ) ;
688- this . uninstallingExtensions . set ( id , promise ) ;
685+ . then ( userExtensions => this . setUninstalled ( ...userExtensions . filter ( u => areSameExtensions ( u . galleryIdentifier , local . galleryIdentifier ) ) ) )
686+ . then ( ( ) => { this . uninstallingExtensions . delete ( local . galleryIdentifier . id ) ; } ) ) ;
687+ this . uninstallingExtensions . set ( local . galleryIdentifier . id , promise ) ;
689688 }
690689 return promise ;
691690 }
692691
693692 private async postUninstallExtension ( extension : ILocalExtension , error ?: Error ) : Promise < void > {
694693 if ( error ) {
695- this . logService . error ( 'Failed to uninstall extension:' , extension . identifier . id , error . message ) ;
694+ this . logService . error ( 'Failed to uninstall extension:' , extension . galleryIdentifier . id , error . message ) ;
696695 } else {
697- this . logService . info ( 'Successfully uninstalled extension:' , extension . identifier . id ) ;
696+ this . logService . info ( 'Successfully uninstalled extension:' , extension . galleryIdentifier . id ) ;
698697 // only report if extension has a mapped gallery extension. UUID identifies the gallery extension.
699- if ( extension . identifier . uuid ) {
698+ if ( extension . galleryIdentifier . uuid ) {
700699 await this . galleryService . reportStatistic ( extension . manifest . publisher , extension . manifest . name , extension . manifest . version , StatisticType . Uninstall ) ;
701700 }
702701 }
@@ -753,7 +752,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
753752 . then ( ( [ uninstalled , extensions ] ) => {
754753 extensions = extensions . filter ( e => ! uninstalled [ e . identifier . id ] ) ;
755754 if ( excludeOutdated ) {
756- const byExtension : ILocalExtension [ ] [ ] = groupByExtension ( extensions , e => ( { id : getGalleryExtensionIdFromLocal ( e ) , uuid : e . identifier . uuid } ) ) ;
755+ const byExtension : ILocalExtension [ ] [ ] = groupByExtension ( extensions , e => e . galleryIdentifier ) ;
757756 extensions = byExtension . map ( p => p . sort ( ( a , b ) => semver . rcompare ( a . manifest . version , b . manifest . version ) ) [ 0 ] ) ;
758757 }
759758 this . logService . info ( 'Scanned user extensions:' , extensions . length ) ;
@@ -808,7 +807,7 @@ export class ExtensionManagementService extends Disposable implements IExtension
808807 const toRemove : ILocalExtension [ ] = [ ] ;
809808
810809 // Outdated extensions
811- const byExtension : ILocalExtension [ ] [ ] = groupByExtension ( extensions , e => ( { id : getGalleryExtensionIdFromLocal ( e ) , uuid : e . identifier . uuid } ) ) ;
810+ const byExtension : ILocalExtension [ ] [ ] = groupByExtension ( extensions , e => e . galleryIdentifier ) ;
812811 toRemove . push ( ...flatten ( byExtension . map ( p => p . sort ( ( a , b ) => semver . rcompare ( a . manifest . version , b . manifest . version ) ) . slice ( 1 ) ) ) ) ;
813812
814813 return Promise . all ( toRemove . map ( extension => this . removeExtension ( extension , 'outdated' ) ) ) ;
@@ -822,8 +821,8 @@ export class ExtensionManagementService extends Disposable implements IExtension
822821 }
823822
824823 private removeExtension ( extension : ILocalExtension , type : string ) : Promise < void > {
825- this . logService . trace ( `Deleting ${ type } extension from disk` , extension . identifier . id ) ;
826- return pfs . rimraf ( extension . location . fsPath ) . then ( ( ) => this . logService . info ( 'Deleted from disk' , extension . identifier . id ) ) ;
824+ this . logService . trace ( `Deleting ${ type } extension from disk` , extension . galleryIdentifier . id , extension . location . fsPath ) ;
825+ return pfs . rimraf ( extension . location . fsPath ) . then ( ( ) => this . logService . info ( 'Deleted from disk' , extension . galleryIdentifier . id , extension . location . fsPath ) ) ;
827826 }
828827
829828 private isUninstalled ( id : string ) : Promise < boolean > {
0 commit comments