judge: auto-remove extra files (#104)

This commit is contained in:
undefined committed 2021-04-20 21:56:31 +08:00
1 parent c977a51de9
commit a7fd32cac9
6 files changed
+26 -2

No files matched your search

+5
View File
@@ -202,10 +202,15 @@ export default class Hydro {
} catch (e) { /* ignore */ }
const version = {};
const filenames = [];
const allFiles = new Set<string>();
for (const file of files) {
allFiles.add(file.name);
version[file.name] = file.etag;
if (etags[file.name] !== file.etag) filenames.push(file.name);
}
for (const name in etags) {
if (!allFiles.has(name)) await fs.rm(path.join(filePath, name));
}
if (filenames.length) {
log.info(`Getting problem data: ${this.config.host}/${domainId}/${pid}`);
if (next) next({ judge_text: '正在同步测试数据,请稍后' });