From 0496b8038d2c3c3f24ce92c0ac0267b3706ef313 Mon Sep 17 00:00:00 2001 From: Menci Date: Sat, 15 Apr 2017 19:11:43 +0800 Subject: [PATCH] Fix can't upload testdata --- models/problem.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/models/problem.js b/models/problem.js index 63a0795..3e03b4e 100644 --- a/models/problem.js +++ b/models/problem.js @@ -259,8 +259,12 @@ class Problem extends Model { await file.destroy(); } - let file = await TestData.create({ - filename: `test_data_${this.id}.zip`, + let filename = `test_data_${this.id}.zip`; + let file = await TestData.findOne({ where: { filename: filename } }); + if (file) await file.destroy(); + + file = await TestData.create({ + filename: filename, md5: key }); await file.save();