From 10cc70b5478c25a9c29197492c792fe39b1c292c Mon Sep 17 00:00:00 2001 From: Menci Date: Sat, 15 Jul 2017 09:12:11 +0800 Subject: [PATCH] Fix download a testdata with no files causes zip the full syzoj dir --- models/problem.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/models/problem.js b/models/problem.js index 1b200d2..515b8d6 100644 --- a/models/problem.js +++ b/models/problem.js @@ -374,8 +374,9 @@ class Problem extends Model { let p7zip = new (require('node-7z')); - let list = await this.listTestdata(), path = require('path'); - await p7zip.add(dir + '.zip', list.files.map(file => path.join(dir, file.filename))); + let list = await this.listTestdata(), path = require('path'), pathlist = list.files.map(file => path.join(dir, file.filename)); + if (!pathlist.length) throw new ErrorMessage('无测试数据。'); + await p7zip.add(dir + '.zip', pathlist); }); }