Skip to content

Commit 9e2d3e7

Browse files
Improve shadowing from PC2
- When no (local) API info is found, don't crash the UI. - For local contest source, check for local submission files in two known places. - Only set problem color from RGB when preset.
1 parent a59ab57 commit 9e2d3e7

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

webapp/src/DataTransferObject/Shadowing/SubmissionFile.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ class SubmissionFile
77
public function __construct(
88
public readonly string $href,
99
public readonly ?string $mime,
10+
public readonly ?string $filename,
1011
) {}
1112
}

webapp/src/Service/ExternalContestSourceService.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public function getApiVersion(): ?string
200200
throw new LogicException('The contest source is not valid');
201201
}
202202

203-
return $this->cachedApiInfoData->version;
203+
return $this->cachedApiInfoData?->version;
204204
}
205205

206206
public function getApiVersionUrl(): ?string
@@ -209,7 +209,7 @@ public function getApiVersionUrl(): ?string
209209
throw new LogicException('The contest source is not valid');
210210
}
211211

212-
return $this->cachedApiInfoData->versionUrl;
212+
return $this->cachedApiInfoData?->versionUrl;
213213
}
214214

215215
public function getApiProviderName(): ?string
@@ -218,7 +218,7 @@ public function getApiProviderName(): ?string
218218
throw new LogicException('The contest source is not valid');
219219
}
220220

221-
return $this->cachedApiInfoData->provider?->name ?? $this->cachedApiInfoData->name;
221+
return $this->cachedApiInfoData?->provider?->name ?? $this->cachedApiInfoData?->name;
222222
}
223223

224224
public function getApiProviderVersion(): ?string
@@ -227,7 +227,7 @@ public function getApiProviderVersion(): ?string
227227
throw new LogicException('The contest source is not valid');
228228
}
229229

230-
return $this->cachedApiInfoData->provider?->version ?? $this->cachedApiInfoData->domjudge?->version;
230+
return $this->cachedApiInfoData?->provider?->version ?? $this->cachedApiInfoData?->domjudge?->version;
231231
}
232232

233233
public function getApiProviderBuildDate(): ?string
@@ -236,7 +236,7 @@ public function getApiProviderBuildDate(): ?string
236236
throw new LogicException('The contest source is not valid');
237237
}
238238

239-
return $this->cachedApiInfoData->provider?->buildDate;
239+
return $this->cachedApiInfoData?->provider?->buildDate;
240240
}
241241

242242
public function getLoadingError(): string
@@ -1017,7 +1017,7 @@ protected function validateAndUpdateProblem(Event $event, EventData $data): void
10171017
);
10181018
$contestProblem->setShortname($data->label);
10191019
}
1020-
if ($contestProblem->getColor() !== ($data->rgb)) {
1020+
if ($data->rgb && $contestProblem->getColor() !== $data->rgb) {
10211021
$this->logger->warning(
10221022
'Contest problem color does not match between feed (%s) and local (%s), updating',
10231023
[$data->rgb, $contestProblem->getColor()]
@@ -1435,6 +1435,14 @@ protected function importSubmission(Event $event, EventData $data): void
14351435
$zipUrl = ($this->basePath ?? '') . $zipUrl;
14361436
}
14371437

1438+
if ($this->source->getType() === ExternalContestSource::TYPE_CONTEST_PACKAGE && $data->files[0]->filename) {
1439+
$zipUrl = $this->source->getSource() . '/submissions/' . $data->id . '/' . $data->files[0]->filename;
1440+
if (!file_exists($zipUrl)) {
1441+
// Common case: submissions are in submissions/<id>.zip
1442+
$zipUrl = $this->source->getSource() . '/submissions/' . $data->id . '.zip';
1443+
}
1444+
}
1445+
14381446
$tmpdir = $this->dj->getDomjudgeTmpDir();
14391447

14401448
// Check if we have a local file.

0 commit comments

Comments
 (0)