| 503 | } |
| 504 | |
| 505 | async deleteScript(uuid: string, deleteBy?: InstallSource) { |
| 506 | let logger = this.logger.with({ uuid }); |
| 507 | const script = await this.scriptDAO.get(uuid); |
| 508 | if (!script) { |
| 509 | logger.error("script not found"); |
| 510 | throw new Error("script not found"); |
| 511 | } |
| 512 | logger = logger.with({ name: script.name }); |
| 513 | const storageName = getStorageName(script); |
| 514 | return this.scriptDAO |
| 515 | .delete(uuid) |
| 516 | .then(async () => { |
| 517 | await this.scriptCodeDAO.delete(uuid); |
| 518 | await this.compiledResourceDAO.delete(uuid); |
| 519 | logger.info("delete success"); |
| 520 | const data = [{ uuid, storageName, type: script.type, deleteBy }] as TDeleteScript[]; |
| 521 | this.mq.publish("deleteScripts", data); |
| 522 | return true; |
| 523 | }) |
| 524 | .catch((e) => { |
| 525 | logger.error("delete error", Logger.E(e)); |
| 526 | throw e; |
| 527 | }); |
| 528 | } |
| 529 | |
| 530 | async deleteScripts(uuids: string[]) { |
| 531 | const logger = this.logger.with({ uuids }); |