Browse Source

Fix can't override testdata

pull/6/head
Menci 8 years ago
parent
commit
a2c22e5c1c
  1. 8
      models/problem.js

8
models/problem.js

@ -248,6 +248,14 @@ class Problem extends Model {
let key = syzoj.utils.md5(buf); let key = syzoj.utils.md5(buf);
await fs.rename(path, TestData.resolvePath(key)); 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({ let file = await TestData.create({
filename: `test_data_${this.id}.zip`, filename: `test_data_${this.id}.zip`,
md5: key md5: key

Loading…
Cancel
Save