From f305d45225fa4e8ccf06cc448ba9e8ce1b88345c Mon Sep 17 00:00:00 2001 From: whyour Date: Wed, 31 May 2023 15:07:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BE=9D=E8=B5=96=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E7=8A=B6=E6=80=81=E6=B5=81=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/data/dependence.ts | 2 +- back/data/open.ts | 7 ------- back/services/dependence.ts | 14 ++++++++------ 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/back/data/dependence.ts b/back/data/dependence.ts index 51ea4556..eec33d1b 100644 --- a/back/data/dependence.ts +++ b/back/data/dependence.ts @@ -15,7 +15,7 @@ export class Dependence { this.status = typeof options.status === 'number' && DependenceStatus[options.status] ? options.status - : DependenceStatus.installing; + : DependenceStatus.queued; this.type = options.type || DependenceTypes.nodejs; this.timestamp = new Date().toString(); this.name = options.name; diff --git a/back/data/open.ts b/back/data/open.ts index ae923ef9..2666e7c8 100644 --- a/back/data/open.ts +++ b/back/data/open.ts @@ -26,13 +26,6 @@ export interface AppToken { export type AppScope = 'envs' | 'crons' | 'configs' | 'scripts' | 'logs'; -export enum CrontabStatus { - 'running', - 'idle', - 'disabled', - 'queued', -} - interface AppInstance extends Model, App {} export const AppModel = sequelize.define('App', { name: { type: DataTypes.STRING, unique: 'name' }, diff --git a/back/services/dependence.ts b/back/services/dependence.ts index 98f2cbe8..7b8bd1c9 100644 --- a/back/services/dependence.ts +++ b/back/services/dependence.ts @@ -105,11 +105,7 @@ export default class DependenceService { isInstall: boolean = true, force: boolean = false, ) { - docs.forEach(async (dep) => { - const status = isInstall - ? DependenceStatus.installing - : DependenceStatus.removing; - await DependenceModel.update({ status }, { where: { id: dep.id } }); + docs.forEach((dep) => { this.installOrUninstallDependencies( [dep], isInstall, @@ -161,6 +157,13 @@ export default class DependenceService { resolve(null); return; } + + const depIds = dependencies.map((x) => x.id) as number[]; + const status = isInstall + ? DependenceStatus.installing + : DependenceStatus.removing; + await DependenceModel.update({ status }, { where: { id: depIds } }); + const socketMessageType = !force ? 'installDependence' : 'uninstallDependence'; @@ -171,7 +174,6 @@ export default class DependenceService { : unInstallDependenceCommandTypes )[dependencies[0].type as any]; const actionText = isInstall ? '安装' : '删除'; - const depIds = dependencies.map((x) => x.id) as number[]; const startTime = dayjs(); const message = `开始${actionText}依赖 ${depNames},开始时间 ${startTime.format(