@@ -44,8 +44,6 @@ import { IProductService } from 'vs/platform/product/common/productService';
44
44
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry' ;
45
45
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity' ;
46
46
import { IUserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile' ;
47
- import { ExtensionSignatureVerificationError , IExtensionSignatureVerificationService } from 'vs/platform/extensionManagement/node/extensionSignatureVerificationService' ;
48
- import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
49
47
50
48
interface InstallableExtension {
51
49
zipPath : string ;
@@ -80,9 +78,7 @@ export class ExtensionManagementService extends AbstractExtensionManagementServi
80
78
@IFileService private readonly fileService : IFileService ,
81
79
@IProductService productService : IProductService ,
82
80
@IUriIdentityService uriIdentityService : IUriIdentityService ,
83
- @IUserDataProfilesService userDataProfilesService : IUserDataProfilesService ,
84
- @IConfigurationService private readonly configurationService : IConfigurationService ,
85
- @IExtensionSignatureVerificationService private readonly extensionSignatureVerificationService : IExtensionSignatureVerificationService
81
+ @IUserDataProfilesService userDataProfilesService : IUserDataProfilesService
86
82
) {
87
83
super ( galleryService , telemetryService , logService , productService , userDataProfilesService ) ;
88
84
const extensionLifecycle = this . _register ( instantiationService . createInstance ( ExtensionsLifecycle ) ) ;
@@ -181,6 +177,11 @@ export class ExtensionManagementService extends AbstractExtensionManagementServi
181
177
return this . extensionsScanner . cleanUp ( removeOutdated ) ;
182
178
}
183
179
180
+ async download ( extension : IGalleryExtension , operation : InstallOperation ) : Promise < URI > {
181
+ const { location } = await this . extensionsDownloader . download ( extension , operation ) ;
182
+ return location ;
183
+ }
184
+
184
185
private async downloadVsix ( vsix : URI ) : Promise < { location : URI ; cleanup : ( ) => Promise < void > } > {
185
186
if ( vsix . scheme === Schemas . file ) {
186
187
return { location : vsix , async cleanup ( ) { } } ;
@@ -207,7 +208,7 @@ export class ExtensionManagementService extends AbstractExtensionManagementServi
207
208
const key = ExtensionKey . create ( extension ) . toString ( ) ;
208
209
installExtensionTask = this . installGalleryExtensionsTasks . get ( key ) ;
209
210
if ( ! installExtensionTask ) {
210
- this . installGalleryExtensionsTasks . set ( key , installExtensionTask = new InstallGalleryExtensionTask ( manifest , extension , options , this . extensionsDownloader , this . extensionsScanner , this . logService , this . configurationService , this . extensionSignatureVerificationService ) ) ;
211
+ this . installGalleryExtensionsTasks . set ( key , installExtensionTask = new InstallGalleryExtensionTask ( manifest , extension , options , this . extensionsDownloader , this . extensionsScanner , this . logService ) ) ;
211
212
installExtensionTask . waitUntilTaskIsFinished ( ) . then ( ( ) => this . installGalleryExtensionsTasks . delete ( key ) ) ;
212
213
}
213
214
}
@@ -600,8 +601,6 @@ export class InstallGalleryExtensionTask extends InstallExtensionTask {
600
601
private readonly extensionsDownloader : ExtensionsDownloader ,
601
602
extensionsScanner : ExtensionsScanner ,
602
603
logService : ILogService ,
603
- private readonly configurationService : IConfigurationService ,
604
- private readonly extensionVerificationService : IExtensionSignatureVerificationService
605
604
) {
606
605
super ( gallery . identifier , gallery , options , extensionsScanner , logService ) ;
607
606
}
@@ -637,17 +636,22 @@ export class InstallGalleryExtensionTask extends InstallExtensionTask {
637
636
return { local, metadata } ;
638
637
}
639
638
640
- const zipPath = await this . downloadVSIX ( this . gallery , this . _operation ) ;
639
+ const { location , verified } = await this . extensionsDownloader . download ( this . gallery , this . _operation ) ;
641
640
try {
642
- this . wasVerified = await this . verifyExtensionSignature ( zipPath ) ;
643
- this . validateManifest ( zipPath ) ;
644
- const local = await this . installExtension ( { zipPath, key : ExtensionKey . create ( this . gallery ) , metadata } , token ) ;
641
+ this . wasVerified = ! ! verified ;
642
+ this . validateManifest ( location . fsPath ) ;
643
+ const local = await this . installExtension ( { zipPath : location . fsPath , key : ExtensionKey . create ( this . gallery ) , metadata } , token ) ;
645
644
if ( existingExtension && ! this . options . profileLocation && ( existingExtension . targetPlatform !== local . targetPlatform || semver . neq ( existingExtension . manifest . version , local . manifest . version ) ) ) {
646
645
await this . extensionsScanner . setUninstalled ( existingExtension ) ;
647
646
}
648
647
return { local, metadata } ;
649
648
} catch ( error ) {
650
- await this . deleteDownloadedFile ( zipPath ) ;
649
+ try {
650
+ await this . extensionsDownloader . delete ( location ) ;
651
+ } catch ( error ) {
652
+ /* Ignore */
653
+ this . logService . warn ( `Error while deleting the downloaded file` , location . toString ( ) , getErrorMessage ( error ) ) ;
654
+ }
651
655
throw error ;
652
656
}
653
657
}
@@ -660,43 +664,6 @@ export class InstallGalleryExtensionTask extends InstallExtensionTask {
660
664
}
661
665
}
662
666
663
- private async verifyExtensionSignature ( zipPath : string ) : Promise < boolean > {
664
- if ( ! this . gallery . isSigned ) {
665
- return false ;
666
- }
667
- if ( ! this . configurationService . getValue ( 'extensions.verifySignature' ) ) {
668
- return false ;
669
- }
670
- const signatureArchivePath = ( await this . extensionsDownloader . downloadSignatureArchive ( this . gallery ) ) . fsPath ;
671
- try {
672
- return await this . extensionVerificationService . verify ( zipPath , signatureArchivePath ) ;
673
- } catch ( error ) {
674
- await this . deleteDownloadedFile ( signatureArchivePath ) ;
675
- throw new ExtensionManagementError ( ( error as ExtensionSignatureVerificationError ) . code , ExtensionManagementErrorCode . Signature ) ;
676
- }
677
- }
678
-
679
- private async deleteDownloadedFile ( filePath : string ) : Promise < void > {
680
- try {
681
- await this . extensionsDownloader . delete ( URI . file ( filePath ) ) ;
682
- } catch ( error ) {
683
- /* Ignore */
684
- this . logService . warn ( `Error while deleting the downloaded file` , filePath . toString ( ) , getErrorMessage ( error ) ) ;
685
- }
686
- }
687
-
688
- private async downloadVSIX ( extension : IGalleryExtension , operation : InstallOperation ) : Promise < string > {
689
- let zipPath : string | undefined ;
690
- try {
691
- this . logService . trace ( 'Started downloading extension:' , extension . identifier . id ) ;
692
- zipPath = ( await this . extensionsDownloader . downloadVSIX ( extension , operation ) ) . fsPath ;
693
- this . logService . info ( 'Downloaded extension:' , extension . identifier . id , zipPath ) ;
694
- } catch ( error ) {
695
- throw new ExtensionManagementError ( joinErrors ( error ) . message , ExtensionManagementErrorCode . Download ) ;
696
- }
697
- return zipPath ;
698
- }
699
-
700
667
}
701
668
702
669
class InstallVSIXTask extends InstallExtensionTask {
0 commit comments