From fd95549de9a5d8cec09772ee2630bb7521e15e1f Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Mon, 4 Aug 2025 18:31:06 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E6=B8=85=E7=90=86=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E5=A4=87=E4=BB=BD=E7=9A=84=E4=B8=B4=E6=97=B6=E7=9B=AE?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/plugin-admin/plugin-db-backup.ts | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/ui/certd-server/src/plugins/plugin-admin/plugin-db-backup.ts b/packages/ui/certd-server/src/plugins/plugin-admin/plugin-db-backup.ts index 23944edb5..87bfe7fbc 100644 --- a/packages/ui/certd-server/src/plugins/plugin-admin/plugin-db-backup.ts +++ b/packages/ui/certd-server/src/plugins/plugin-admin/plugin-db-backup.ts @@ -202,16 +202,22 @@ export class DBBackupPlugin extends AbstractPlusTaskPlugin { const backupDir = this.backupDir || defaultBackupDir; const backupFilePath = `${backupDir}/${dbZipFilename}`; - if (this.backupMode === 'local') { - await this.localBackup(dbZipPath, backupDir, backupFilePath); - } else if (this.backupMode === 'ssh') { - await this.sshBackup(dbZipPath, backupDir, backupFilePath); - } else if (this.backupMode === 'oss') { - await this.ossBackup(dbZipPath, backupDir, backupFilePath); - } else { - throw new Error(`不支持的备份方式:${this.backupMode}`); + try{ + if (this.backupMode === 'local') { + await this.localBackup(dbZipPath, backupDir, backupFilePath); + } else if (this.backupMode === 'ssh') { + await this.sshBackup(dbZipPath, backupDir, backupFilePath); + } else if (this.backupMode === 'oss') { + await this.ossBackup(dbZipPath, backupDir, backupFilePath); + } else { + throw new Error(`不支持的备份方式:${this.backupMode}`); + } + }finally{ + //删除临时目录 + await fs.promises.rm(tempDir, {recursive: true, force: true}); } + this.logger.info('数据库备份完成'); }