|  | @@ -1023,15 +1023,15 @@ module.exports = app => {
 | 
	
		
			
				|  |  |           * @param {Object} ctx - 全局上下文
 | 
	
		
			
				|  |  |           */
 | 
	
		
			
				|  |  |          async downloadZip(ctx) {
 | 
	
		
			
				|  |  | +            const zipFilename = `${ctx.tender.data.name}-台账分解-附件.zip`;
 | 
	
		
			
				|  |  | +            const time = Date.now();
 | 
	
		
			
				|  |  | +            const zipPath = `app/public/upload/${ctx.tender.id}/ledger/fu_jian_zip${time}.zip`;
 | 
	
		
			
				|  |  |              const responseData = {
 | 
	
		
			
				|  |  |                  err: 0,
 | 
	
		
			
				|  |  |                  msg: '',
 | 
	
		
			
				|  |  |              };
 | 
	
		
			
				|  |  |              try {
 | 
	
		
			
				|  |  |                  const { fileIds = [] } = JSON.parse(ctx.request.body.data);
 | 
	
		
			
				|  |  | -                const zipFilename = `${ctx.tender.data.name}-台账分解-附件.zip`;
 | 
	
		
			
				|  |  | -                const time = Date.now();
 | 
	
		
			
				|  |  | -                const zipPath = `app/public/upload/${ctx.tender.id}/ledger/fu_jian_zip${time}.zip`;
 | 
	
		
			
				|  |  |                  const size = await ctx.service.ledgerAtt.compressedFile(fileIds, zipPath);
 | 
	
		
			
				|  |  |                  // 解决中文无法下载问题
 | 
	
		
			
				|  |  |                  const userAgent = (ctx.request.header['user-agent'] || '').toLowerCase();
 | 
	
	
		
			
				|  | @@ -1056,11 +1056,21 @@ module.exports = app => {
 | 
	
		
			
				|  |  |                          fs.unlinkSync(path.resolve(this.app.baseDir, zipPath));
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  });
 | 
	
		
			
				|  |  | -                readStream.on('error', error => {
 | 
	
		
			
				|  |  | -                    this.log(error);
 | 
	
		
			
				|  |  | +                // fs的错误不能被try catch捕捉
 | 
	
		
			
				|  |  | +                readStream.on('error', err => {
 | 
	
		
			
				|  |  | +                    this.log(err);
 | 
	
		
			
				|  |  | +                    if (fs.existsSync(path.resolve(this.app.baseDir, zipPath))) {
 | 
	
		
			
				|  |  | +                        fs.unlinkSync(path.resolve(this.app.baseDir, zipPath));
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                    responseData.err = 1;
 | 
	
		
			
				|  |  | +                    responseData.msg = err.toString();
 | 
	
		
			
				|  |  | +                    ctx.body = responseData;
 | 
	
		
			
				|  |  |                  });
 | 
	
		
			
				|  |  |              } catch (err) {
 | 
	
		
			
				|  |  |                  this.log(err);
 | 
	
		
			
				|  |  | +                if (fs.existsSync(path.resolve(this.app.baseDir, zipPath))) {
 | 
	
		
			
				|  |  | +                    fs.unlinkSync(path.resolve(this.app.baseDir, zipPath));
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  |                  this.setMessage(err.toString(), this.messageType.ERROR);
 | 
	
		
			
				|  |  |                  responseData.err = 1;
 | 
	
		
			
				|  |  |                  responseData.msg = err.toString();
 |