laiguoran 5 vuotta sitten
vanhempi
commit
612fffdbd3
1 muutettua tiedostoa jossa 6 lisäystä ja 2 poistoa
  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 });