Browse Source

perf: 优化删除预付款记录时删除文件的逻辑

lanjianrong 3 năm trước cách đây
mục cha
commit
98db2402c4
1 tập tin đã thay đổi với 4 bổ sung1 xóa
  1. 4 1
      app/service/advance.js

+ 4 - 1
app/service/advance.js

@@ -220,7 +220,10 @@ module.exports = app => {
                 // 先删除文件
                 for (let i = 0; i < fileInfo.length; i++) {
                     const file = fileInfo[i];
-                    fs.unlinkSync(path.resolve(this.app.baseDir, './app', file.filepath));
+                    if (fs.existsSync(path.resolve(this.app.baseDir, './app', file.filepath))) {
+                        fs.unlinkSync(path.resolve(this.app.baseDir, './app', file.filepath));
+                        // fs.unlinkSync(path.resolve(this.app.baseDir, zipPath));
+                    }
                 }
                 // 删除审批记录
                 await transaction.delete(this.ctx.service.advanceAudit.tableName, { vid: id, tid });