Skip to content
Snippets Groups Projects
Commit a7232e67 authored by Xavier Jouslin de Noray's avatar Xavier Jouslin de Noray
Browse files

PluginManager: resolve architecture to be able to handle dynamically all platform's queries

Change-Id: Ic0f332b4c1615c58419937a200cc844d767afe2a
parent f1d30708
Branches
No related tags found
No related merge requests found
...@@ -25,7 +25,7 @@ import {basename, extname} from 'path'; ...@@ -25,7 +25,7 @@ import {basename, extname} from 'path';
@Service() @Service()
export class PluginsManager { export class PluginsManager {
private plugins: Plugins[] = []; private plugins: Plugins[] = [];
private readonly archesResolution = new Map<string, string[]>();
constructor( constructor(
private readonly fileManager: FileManagerService, private readonly fileManager: FileManagerService,
private readonly certificateManager: CertificateManagerService private readonly certificateManager: CertificateManagerService
...@@ -131,7 +131,7 @@ export class PluginsManager { ...@@ -131,7 +131,7 @@ export class PluginsManager {
async getNewPlugin( async getNewPlugin(
path: string, path: string,
arches: string[] platforms: string[]
): Promise<Plugins | undefined> { ): Promise<Plugins | undefined> {
try { try {
const plugin = await this.readManifest(path); const plugin = await this.readManifest(path);
...@@ -140,9 +140,11 @@ export class PluginsManager { ...@@ -140,9 +140,11 @@ export class PluginsManager {
path, path,
basename(path, extname(path)) + '.crt' basename(path, extname(path)) + '.crt'
); );
if (issuer === undefined) { const arches = await this.getAllPluginArches(path);
if (issuer === undefined || arches === undefined) {
return; return;
} }
this.addPluginArch(platforms, arches);
return { return {
id: plugin.id, id: plugin.id,
name: plugin.name, name: plugin.name,
...@@ -330,4 +332,24 @@ export class PluginsManager { ...@@ -330,4 +332,24 @@ export class PluginsManager {
return ''; return '';
}); });
} }
private addPluginArch(platforms: string[], arches: string[]): void {
for (const platform of platforms) {
if (this.archesResolution.has(platform)) {
const oldArches = this.archesResolution.get(platform);
if (oldArches === undefined) {
this.archesResolution.set(platform, arches);
continue;
}
for (const arch of arches) {
if (!oldArches.includes(arch)) {
oldArches.push(arch);
}
}
this.archesResolution.set(platform, oldArches);
} else {
this.archesResolution.set(platform, arches);
}
}
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment