vjudge: only add language if mapping doesn't exist

This commit is contained in:
undefined committed 2025-08-03 20:53:09 +08:00
1 parent 8df1e3ae5e
commit 00ee96a191
1 file changed
+7 -1
+7 -1
View File
@@ -219,9 +219,15 @@ class VJudgeService extends Service {
}
async updateLangs(provider: string, mapping: Record<string, Partial<LangConfig>>) {
const config = yaml.load(SystemModel.get('hydrooj.langs'));
const config = yaml.load(SystemModel.get('hydrooj.langs')) as Record<string, Partial<LangConfig>>;
const old = yaml.dump(config);
const existingMappings: Set<string> = new Set();
for (const key in config) {
const target = config[key]?.validAs?.[provider];
if (target) existingMappings.add(target);
}
for (const key in mapping) {
if (existingMappings.has(mapping[key].key)) continue;
config[key] ||= {
execute: '/bin/echo For remote judge only',
hidden: true,