From a2c22e5c1ce7820a72a80ffd564102d9c3a94132 Mon Sep 17 00:00:00 2001 From: Menci Date: Sat, 18 Feb 2017 16:28:03 +0800 Subject: [PATCH] Fix can't override testdata --- models/problem.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/models/problem.js b/models/problem.js index 856008e..79be434 100644 --- a/models/problem.js +++ b/models/problem.js @@ -248,6 +248,14 @@ class Problem extends Model { let key = syzoj.utils.md5(buf); await fs.rename(path, TestData.resolvePath(key)); + if (this.testdata_id) { + let tmp = this.testdata_id; + this.testdata_id = null; + await this.save(); + let file = await TestData.fromID(tmp); + await file.destroy(); + } + let file = await TestData.create({ filename: `test_data_${this.id}.zip`, md5: key