mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
vjudge: only add language if mapping doesn't exist
This commit is contained in:
1 file changed
+7
-1
@@ -219,9 +219,15 @@ class VJudgeService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async updateLangs(provider: string, mapping: Record<string, Partial<LangConfig>>) {
|
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 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) {
|
for (const key in mapping) {
|
||||||
|
if (existingMappings.has(mapping[key].key)) continue;
|
||||||
config[key] ||= {
|
config[key] ||= {
|
||||||
execute: '/bin/echo For remote judge only',
|
execute: '/bin/echo For remote judge only',
|
||||||
hidden: true,
|
hidden: true,
|
||||||
|
|||||||
Reference in new issue
Block a user