瀏覽代碼

期删除bug

laiguoran 5 年之前
父節點
當前提交
612fffdbd3
共有 1 個文件被更改,包括 6 次插入2 次删除
  1. 6 2
      app/service/stage.js

+ 6 - 2
app/service/stage.js

@@ -308,7 +308,9 @@ module.exports = app => {
                         if (pt.attachment !== null && pt.attachment !== '') {
                             const payAttList = JSON.parse(pt.attachment);
                             for (const pat of payAttList) {
-                                await fs.unlinkSync(path.join(this.app.baseDir, pat.filepath));
+                                if (fs.existsSync(path.join(this.app.baseDir, pat.filepath))) {
+                                    await fs.unlinkSync(path.join(this.app.baseDir, pat.filepath));
+                                }
                             }
                         }
                     }
@@ -318,7 +320,9 @@ module.exports = app => {
                 const attList = await this.ctx.service.stageAtt.getAllDataByCondition({ where: { sid: id } });
                 if (attList.length !== 0) {
                     for (const att of attList) {
-                        await fs.unlinkSync(path.join(this.app.baseDir, att.filepath));
+                        if (fs.existsSync(path.join(this.app.baseDir, att.filepath))) {
+                            await fs.unlinkSync(path.join(this.app.baseDir, att.filepath));
+                        }
                     }
                 }
                 await transaction.delete(this.ctx.service.stageAtt.tableName, { sid: id });