@@ -321,7 +321,6 @@ export abstract class AbstractExtensionManagementService extends CommontExtensio
321321 const isApplicationScoped = options . isApplicationScoped || options . isBuiltin || isApplicationScopedExtension ( manifest ) ;
322322 const installExtensionTaskOptions : InstallExtensionTaskOptions = {
323323 ...options ,
324- installOnlyNewlyAddedFromExtensionPack : options . installOnlyNewlyAddedFromExtensionPack ?? ! URI . isUri ( extension ) /* always true for gallery extensions */ ,
325324 isApplicationScoped,
326325 profileLocation : isApplicationScoped ? this . userDataProfilesService . defaultProfile . extensionsResource : options . profileLocation ?? this . getCurrentExtensionsManifestLocation ( ) ,
327326 productVersion : options . productVersion ?? { version : this . productService . version , date : this . productService . date }
@@ -342,11 +341,13 @@ export abstract class AbstractExtensionManagementService extends CommontExtensio
342341 this . logService . info ( 'Installing the extension without checking dependencies and pack' , task . identifier . id ) ;
343342 } else {
344343 try {
345- const allDepsAndPackExtensionsToInstall = await this . getAllDepsAndPackExtensions ( task . identifier , task . manifest , ! ! task . options . installOnlyNewlyAddedFromExtensionPack , ! ! task . options . installPreReleaseVersion , task . options . profileLocation , task . options . productVersion ) ;
344+ const allDepsAndPackExtensionsToInstall = await this . getAllDepsAndPackExtensions ( task . identifier , task . manifest , ! ! task . options . installPreReleaseVersion , task . options . productVersion ) ;
346345 const installed = await this . getInstalled ( undefined , task . options . profileLocation , task . options . productVersion ) ;
347346 const options : InstallExtensionTaskOptions = { ...task . options , context : { ...task . options . context , [ EXTENSION_INSTALL_DEP_PACK_CONTEXT ] : true } } ;
348347 for ( const { gallery, manifest } of distinct ( allDepsAndPackExtensionsToInstall , ( { gallery } ) => gallery . identifier . id ) ) {
349- if ( installed . some ( ( { identifier } ) => areSameExtensions ( identifier , gallery . identifier ) ) ) {
348+ const existing = installed . find ( e => areSameExtensions ( e . identifier , gallery . identifier ) ) ;
349+ // Skip if the extension is already installed and has the same application scope
350+ if ( existing && existing . isApplicationScoped === ! ! options . isApplicationScoped ) {
350351 continue ;
351352 }
352353 createInstallExtensionTask ( manifest , gallery , options , task ) ;
@@ -578,12 +579,11 @@ export abstract class AbstractExtensionManagementService extends CommontExtensio
578579 throw error ;
579580 }
580581
581- private async getAllDepsAndPackExtensions ( extensionIdentifier : IExtensionIdentifier , manifest : IExtensionManifest , getOnlyNewlyAddedFromExtensionPack : boolean , installPreRelease : boolean , profile : URI | undefined , productVersion : IProductVersion ) : Promise < { gallery : IGalleryExtension ; manifest : IExtensionManifest } [ ] > {
582+ private async getAllDepsAndPackExtensions ( extensionIdentifier : IExtensionIdentifier , manifest : IExtensionManifest , installPreRelease : boolean , productVersion : IProductVersion ) : Promise < { gallery : IGalleryExtension ; manifest : IExtensionManifest } [ ] > {
582583 if ( ! this . galleryService . isEnabled ( ) ) {
583584 return [ ] ;
584585 }
585586
586- const installed = await this . getInstalled ( undefined , profile , productVersion ) ;
587587 const knownIdentifiers : IExtensionIdentifier [ ] = [ ] ;
588588
589589 const allDependenciesAndPacks : { gallery : IGalleryExtension ; manifest : IExtensionManifest } [ ] = [ ] ;
@@ -592,13 +592,9 @@ export abstract class AbstractExtensionManagementService extends CommontExtensio
592592 const dependecies : string [ ] = manifest . extensionDependencies || [ ] ;
593593 const dependenciesAndPackExtensions = [ ...dependecies ] ;
594594 if ( manifest . extensionPack ) {
595- const existing = getOnlyNewlyAddedFromExtensionPack ? installed . find ( e => areSameExtensions ( e . identifier , extensionIdentifier ) ) : undefined ;
596595 for ( const extension of manifest . extensionPack ) {
597- // add only those extensions which are new in currently installed extension
598- if ( ! ( existing && existing . manifest . extensionPack && existing . manifest . extensionPack . some ( old => areSameExtensions ( { id : old } , { id : extension } ) ) ) ) {
599- if ( dependenciesAndPackExtensions . every ( e => ! areSameExtensions ( { id : e } , { id : extension } ) ) ) {
600- dependenciesAndPackExtensions . push ( extension ) ;
601- }
596+ if ( dependenciesAndPackExtensions . every ( e => ! areSameExtensions ( { id : e } , { id : extension } ) ) ) {
597+ dependenciesAndPackExtensions . push ( extension ) ;
602598 }
603599 }
604600 }
0 commit comments