Skip to content

Commit 6037448

Browse files
committed
filter application extensions from non default profile
1 parent 836231f commit 6037448

File tree

5 files changed

+36
-25
lines changed

5 files changed

+36
-25
lines changed

src/vs/platform/extensionManagement/common/extensionsScannerService.ts

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ import { areSameExtensions, computeTargetPlatform, ExtensionKey, getExtensionId,
2727
import { ExtensionType, ExtensionIdentifier, IExtensionManifest, TargetPlatform, IExtensionIdentifier, IRelaxedExtensionManifest, UNDEFINED_PUBLISHER, IExtensionDescription, BUILTIN_MANIFEST_CACHE_FILE, USER_MANIFEST_CACHE_FILE, MANIFEST_CACHE_FOLDER } from 'vs/platform/extensions/common/extensions';
2828
import { validateExtensionManifest } from 'vs/platform/extensions/common/extensionValidator';
2929
import { FileOperationResult, IFileService, toFileOperationResult } from 'vs/platform/files/common/files';
30-
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
30+
import { createDecorator, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
3131
import { ILogService } from 'vs/platform/log/common/log';
3232
import { IProductService } from 'vs/platform/product/common/productService';
3333
import { Emitter, Event } from 'vs/base/common/event';
3434
import { revive } from 'vs/base/common/marshalling';
3535
import { IExtensionsProfileScannerService, IScannedProfileExtension } from 'vs/platform/extensionManagement/common/extensionsProfileScannerService';
3636
import { IUserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile';
37+
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity';
3738

3839
export type IScannedExtensionManifest = IRelaxedExtensionManifest & { __metadata?: Metadata };
3940

@@ -139,9 +140,9 @@ export abstract class AbstractExtensionsScannerService extends Disposable implem
139140
readonly onDidChangeCache = this._onDidChangeCache.event;
140141

141142
private readonly obsoleteFile = joinPath(this.userExtensionsLocation, '.obsolete');
142-
private readonly systemExtensionsCachedScanner = this._register(new CachedExtensionsScanner(joinPath(this.cacheLocation, BUILTIN_MANIFEST_CACHE_FILE), this.obsoleteFile, this.extensionsProfileScannerService, this.fileService, this.logService));
143-
private readonly userExtensionsCachedScanner = this._register(new CachedExtensionsScanner(joinPath(this.cacheLocation, USER_MANIFEST_CACHE_FILE), this.obsoleteFile, this.extensionsProfileScannerService, this.fileService, this.logService));
144-
private readonly extensionsScanner = this._register(new ExtensionsScanner(this.obsoleteFile, this.extensionsProfileScannerService, this.fileService, this.logService));
143+
private readonly systemExtensionsCachedScanner = this._register(this.instantiationService.createInstance(CachedExtensionsScanner, joinPath(this.cacheLocation, BUILTIN_MANIFEST_CACHE_FILE), this.obsoleteFile));
144+
private readonly userExtensionsCachedScanner = this._register(this.instantiationService.createInstance(CachedExtensionsScanner, joinPath(this.cacheLocation, USER_MANIFEST_CACHE_FILE), this.obsoleteFile));
145+
private readonly extensionsScanner = this._register(this.instantiationService.createInstance(ExtensionsScanner, this.obsoleteFile));
145146

146147
constructor(
147148
readonly systemExtensionsLocation: URI,
@@ -154,6 +155,7 @@ export abstract class AbstractExtensionsScannerService extends Disposable implem
154155
@ILogService protected readonly logService: ILogService,
155156
@IEnvironmentService private readonly environmentService: IEnvironmentService,
156157
@IProductService private readonly productService: IProductService,
158+
@IInstantiationService private readonly instantiationService: IInstantiationService,
157159
) {
158160
super();
159161

@@ -476,9 +478,10 @@ class ExtensionsScanner extends Disposable {
476478

477479
constructor(
478480
private readonly obsoleteFile: URI,
479-
protected readonly extensionsProfileScannerService: IExtensionsProfileScannerService,
480-
protected readonly fileService: IFileService,
481-
protected readonly logService: ILogService
481+
@IExtensionsProfileScannerService protected readonly extensionsProfileScannerService: IExtensionsProfileScannerService,
482+
@IUriIdentityService protected readonly uriIdentityService: IUriIdentityService,
483+
@IFileService protected readonly fileService: IFileService,
484+
@ILogService protected readonly logService: ILogService
482485
) {
483486
super();
484487
}
@@ -518,15 +521,13 @@ class ExtensionsScanner extends Disposable {
518521
}
519522

520523
private async scanExtensionsFromProfile(input: ExtensionScannerInput): Promise<IRelaxedScannedExtension[]> {
521-
const profileExtensions = await this.scanExtensionsFromProfileResource(input.location, () => true, input);
522-
const applicationExtensions = await this.scanApplicationExtensions(input);
523-
return [...profileExtensions, ...applicationExtensions];
524-
}
525-
526-
private async scanApplicationExtensions(input: ExtensionScannerInput): Promise<IRelaxedScannedExtension[]> {
527-
return input.applicationExtensionslocation
528-
? this.scanExtensionsFromProfileResource(input.applicationExtensionslocation, (e) => !!e.metadata?.isApplicationScoped, input)
529-
: [];
524+
let profileExtensions = await this.scanExtensionsFromProfileResource(input.location, () => true, input);
525+
if (input.applicationExtensionslocation && !this.uriIdentityService.extUri.isEqual(input.location, input.applicationExtensionslocation)) {
526+
profileExtensions = profileExtensions.filter(e => !e.metadata?.isApplicationScoped);
527+
const applicationExtensions = await this.scanExtensionsFromProfileResource(input.applicationExtensionslocation, (e) => !!e.metadata?.isApplicationScoped, input);
528+
profileExtensions.push(...applicationExtensions);
529+
}
530+
return profileExtensions;
530531
}
531532

532533
private async scanExtensionsFromProfileResource(profileResource: URI, filter: (extensionInfo: IScannedProfileExtension) => boolean, input: ExtensionScannerInput): Promise<IRelaxedScannedExtension[]> {
@@ -845,11 +846,12 @@ class CachedExtensionsScanner extends ExtensionsScanner {
845846
constructor(
846847
private readonly cacheFile: URI,
847848
obsoleteFile: URI,
848-
extensionsProfileScannerService: IExtensionsProfileScannerService,
849-
fileService: IFileService,
850-
logService: ILogService
849+
@IExtensionsProfileScannerService extensionsProfileScannerService: IExtensionsProfileScannerService,
850+
@IUriIdentityService uriIdentityService: IUriIdentityService,
851+
@IFileService fileService: IFileService,
852+
@ILogService logService: ILogService
851853
) {
852-
super(obsoleteFile, extensionsProfileScannerService, fileService, logService);
854+
super(obsoleteFile, extensionsProfileScannerService, uriIdentityService, fileService, logService);
853855
}
854856

855857
override async scanExtensions(input: ExtensionScannerInput): Promise<IRelaxedScannedExtension[]> {
@@ -947,13 +949,14 @@ export class NativeExtensionsScannerService extends AbstractExtensionsScannerSer
947949
logService: ILogService,
948950
environmentService: IEnvironmentService,
949951
productService: IProductService,
952+
instantiationService: IInstantiationService,
950953
) {
951954
super(
952955
systemExtensionsLocation,
953956
userExtensionsLocation,
954957
joinPath(userHome, '.vscode-oss-dev', 'extensions', 'control.json'),
955958
joinPath(userDataPath, MANIFEST_CACHE_FOLDER),
956-
userDataProfilesService, extensionsProfileScannerService, fileService, logService, environmentService, productService);
959+
userDataProfilesService, extensionsProfileScannerService, fileService, logService, environmentService, productService, instantiationService);
957960
this.translationsPromise = (async () => {
958961
if (platform.translationsConfigFile) {
959962
try {

src/vs/platform/extensionManagement/electron-sandbox/extensionsScannerService.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { IExtensionsProfileScannerService } from 'vs/platform/extensionManagemen
99
import { IExtensionsScannerService, NativeExtensionsScannerService, } from 'vs/platform/extensionManagement/common/extensionsScannerService';
1010
import { IFileService } from 'vs/platform/files/common/files';
1111
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
12+
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
1213
import { ILogService } from 'vs/platform/log/common/log';
1314
import { IProductService } from 'vs/platform/product/common/productService';
1415
import { IUserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile';
@@ -22,13 +23,14 @@ export class ExtensionsScannerService extends NativeExtensionsScannerService imp
2223
@ILogService logService: ILogService,
2324
@INativeEnvironmentService environmentService: INativeEnvironmentService,
2425
@IProductService productService: IProductService,
26+
@IInstantiationService instantiationService: IInstantiationService,
2527
) {
2628
super(
2729
URI.file(environmentService.builtinExtensionsPath),
2830
URI.file(environmentService.extensionsPath),
2931
environmentService.userHome,
3032
URI.file(environmentService.userDataPath),
31-
userDataProfilesService, extensionsProfileScannerService, fileService, logService, environmentService, productService);
33+
userDataProfilesService, extensionsProfileScannerService, fileService, logService, environmentService, productService, instantiationService);
3234
}
3335

3436
}

src/vs/platform/extensionManagement/node/extensionsScannerService.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { INativeEnvironmentService } from 'vs/platform/environment/common/enviro
88
import { IExtensionsProfileScannerService } from 'vs/platform/extensionManagement/common/extensionsProfileScannerService';
99
import { IExtensionsScannerService, NativeExtensionsScannerService, } from 'vs/platform/extensionManagement/common/extensionsScannerService';
1010
import { IFileService } from 'vs/platform/files/common/files';
11+
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
1112
import { ILogService } from 'vs/platform/log/common/log';
1213
import { IProductService } from 'vs/platform/product/common/productService';
1314
import { IUserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile';
@@ -21,13 +22,14 @@ export class ExtensionsScannerService extends NativeExtensionsScannerService imp
2122
@ILogService logService: ILogService,
2223
@INativeEnvironmentService environmentService: INativeEnvironmentService,
2324
@IProductService productService: IProductService,
25+
@IInstantiationService instantiationService: IInstantiationService,
2426
) {
2527
super(
2628
URI.file(environmentService.builtinExtensionsPath),
2729
URI.file(environmentService.extensionsPath),
2830
environmentService.userHome,
2931
URI.file(environmentService.userDataPath),
30-
userDataProfilesService, extensionsProfileScannerService, fileService, logService, environmentService, productService);
32+
userDataProfilesService, extensionsProfileScannerService, fileService, logService, environmentService, productService, instantiationService);
3133
}
3234

3335
}

src/vs/platform/extensionManagement/test/node/extensionsScannerService.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { ExtensionType, IExtensionManifest, MANIFEST_CACHE_FOLDER, TargetPlatfor
1414
import { IFileService } from 'vs/platform/files/common/files';
1515
import { FileService } from 'vs/platform/files/common/fileService';
1616
import { InMemoryFileSystemProvider } from 'vs/platform/files/common/inMemoryFilesystemProvider';
17+
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
1718
import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock';
1819
import { ILogService, NullLogService } from 'vs/platform/log/common/log';
1920
import { IProductService } from 'vs/platform/product/common/productService';
@@ -31,13 +32,14 @@ class ExtensionsScannerService extends AbstractExtensionsScannerService implemen
3132
@ILogService logService: ILogService,
3233
@INativeEnvironmentService nativeEnvironmentService: INativeEnvironmentService,
3334
@IProductService productService: IProductService,
35+
@IInstantiationService instantiationService: IInstantiationService,
3436
) {
3537
super(
3638
URI.file(nativeEnvironmentService.builtinExtensionsPath),
3739
URI.file(nativeEnvironmentService.extensionsPath),
3840
joinPath(nativeEnvironmentService.userHome, '.vscode-oss-dev', 'extensions', 'control.json'),
3941
joinPath(ROOT, MANIFEST_CACHE_FOLDER),
40-
userDataProfilesService, extensionsProfileScannerService, fileService, logService, nativeEnvironmentService, productService);
42+
userDataProfilesService, extensionsProfileScannerService, fileService, logService, nativeEnvironmentService, productService, instantiationService);
4143
}
4244

4345
protected async getTranslations(language: string): Promise<Translations> {

src/vs/server/node/extensionsScannerService.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { IExtensionsProfileScannerService } from 'vs/platform/extensionManagemen
1010
import { AbstractExtensionsScannerService, IExtensionsScannerService, Translations } from 'vs/platform/extensionManagement/common/extensionsScannerService';
1111
import { MANIFEST_CACHE_FOLDER } from 'vs/platform/extensions/common/extensions';
1212
import { IFileService } from 'vs/platform/files/common/files';
13+
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
1314
import { ILogService } from 'vs/platform/log/common/log';
1415
import { IProductService } from 'vs/platform/product/common/productService';
1516
import { IUserDataProfilesService } from 'vs/platform/userDataProfile/common/userDataProfile';
@@ -24,13 +25,14 @@ export class ExtensionsScannerService extends AbstractExtensionsScannerService i
2425
@ILogService logService: ILogService,
2526
@INativeEnvironmentService private readonly nativeEnvironmentService: INativeEnvironmentService,
2627
@IProductService productService: IProductService,
28+
@IInstantiationService instantiationService: IInstantiationService,
2729
) {
2830
super(
2931
URI.file(nativeEnvironmentService.builtinExtensionsPath),
3032
URI.file(nativeEnvironmentService.extensionsPath),
3133
joinPath(nativeEnvironmentService.userHome, '.vscode-oss-dev', 'extensions', 'control.json'),
3234
joinPath(URI.file(nativeEnvironmentService.userDataPath), MANIFEST_CACHE_FOLDER),
33-
userDataProfilesService, extensionsProfileScannerService, fileService, logService, nativeEnvironmentService, productService);
35+
userDataProfilesService, extensionsProfileScannerService, fileService, logService, nativeEnvironmentService, productService, instantiationService);
3436
}
3537

3638
protected async getTranslations(language: string): Promise<Translations> {

0 commit comments

Comments
 (0)