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';
@Service()
export class PluginsManager {
private plugins: Plugins[] = [];
private readonly archesResolution = new Map<string, string[]>();
constructor(
private readonly fileManager: FileManagerService,
private readonly certificateManager: CertificateManagerService
......@@ -131,7 +131,7 @@ export class PluginsManager {
async getNewPlugin(
path: string,
arches: string[]
platforms: string[]
): Promise<Plugins | undefined> {
try {
const plugin = await this.readManifest(path);
......@@ -140,9 +140,11 @@ export class PluginsManager {
path,
basename(path, extname(path)) + '.crt'
);
if (issuer === undefined) {
const arches = await this.getAllPluginArches(path);
if (issuer === undefined || arches === undefined) {
return;
}
this.addPluginArch(platforms, arches);
return {
id: plugin.id,
name: plugin.name,
......@@ -330,4 +332,24 @@ export class PluginsManager {
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