依赖改为串行安装

This commit is contained in:
whyour 2022-05-28 19:41:37 +08:00
parent 8b1906c786
commit 8d2c62d6d1
2 changed files with 17 additions and 9 deletions

View File

@ -27,11 +27,7 @@ export default async () => {
if (Object.prototype.hasOwnProperty.call(groups, key)) {
const group = groups[key];
const depIds = group.map((x) => x.id);
for (const dep of depIds) {
if (dep) {
await dependenceService.reInstall([dep]);
}
}
await dependenceService.reInstall(depIds as number[]);
}
}
});

View File

@ -27,7 +27,7 @@ export default class DependenceService {
return tab;
});
const docs = await this.insert(tabs);
this.installOrUninstallDependencies(docs);
await this.installDependenceOneByOne(docs);
return docs;
}
@ -47,7 +47,7 @@ export default class DependenceService {
status: DependenceStatus.installing,
});
const newDoc = await this.updateDb(tab);
this.installOrUninstallDependencies([newDoc]);
await this.installDependenceOneByOne([newDoc]);
return newDoc;
}
@ -62,7 +62,7 @@ export default class DependenceService {
{ where: { id: ids } },
);
const docs = await DependenceModel.findAll({ where: { id: ids } });
this.installOrUninstallDependencies(docs, false, force);
await this.installDependenceOneByOne(docs, false, force);
return docs;
}
@ -98,6 +98,18 @@ export default class DependenceService {
}
}
private async installDependenceOneByOne(
docs: Dependence[],
isInstall: boolean = true,
force: boolean = false,
) {
for (const dep of docs) {
if (dep) {
await this.installOrUninstallDependencies([dep], isInstall, force);
}
}
}
public async reInstall(ids: number[]): Promise<Dependence[]> {
await DependenceModel.update(
{ status: DependenceStatus.installing, log: [] },
@ -105,7 +117,7 @@ export default class DependenceService {
);
const docs = await DependenceModel.findAll({ where: { id: ids } });
this.installOrUninstallDependencies(docs);
await this.installDependenceOneByOne(docs);
return docs;
}