|
@@ -308,7 +308,9 @@ module.exports = app => {
|
|
if (pt.attachment !== null && pt.attachment !== '') {
|
|
if (pt.attachment !== null && pt.attachment !== '') {
|
|
const payAttList = JSON.parse(pt.attachment);
|
|
const payAttList = JSON.parse(pt.attachment);
|
|
for (const pat of payAttList) {
|
|
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 } });
|
|
const attList = await this.ctx.service.stageAtt.getAllDataByCondition({ where: { sid: id } });
|
|
if (attList.length !== 0) {
|
|
if (attList.length !== 0) {
|
|
for (const att of attList) {
|
|
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 });
|
|
await transaction.delete(this.ctx.service.stageAtt.tableName, { sid: id });
|