Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions webapp/src/Service/ExternalContestSourceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -1468,26 +1468,31 @@ protected function importSubmission(Event $event, EventData $data): void
}

if ($submissionDownloadSucceeded) {
try {
$response = $this->httpClient->request('GET', $zipUrl);
$ziphandler = fopen($zipFile, 'w');
if ($response->getStatusCode() !== 200) {
// TODO: Retry a couple of times.
$tries = 1;
do {
try {
$response = $this->httpClient->request('GET', $zipUrl);
$ziphandler = fopen($zipFile, 'w');
if ($response->getStatusCode() !== 200) {
$this->addOrUpdateWarning($event, $data->id, ExternalSourceWarning::TYPE_SUBMISSION_ERROR, [
'message' => "Cannot download ZIP from $zipUrl after trying $tries times",
]);
$submissionDownloadSucceeded = false;
// Sleep a bit before retrying
sleep(3);
}
$tries++;
} catch (TransportExceptionInterface $e) {
$this->addOrUpdateWarning($event, $data->id, ExternalSourceWarning::TYPE_SUBMISSION_ERROR, [
'message' => 'Cannot download ZIP from ' . $zipUrl,
'message' => "Cannot download ZIP from $zipUrl after trying $tries times: " . $e->getMessage(),
]);
if (isset($ziphandler)) {
fclose($ziphandler);
}
unlink($zipFile);
$submissionDownloadSucceeded = false;
}
} catch (TransportExceptionInterface $e) {
$this->addOrUpdateWarning($event, $data->id, ExternalSourceWarning::TYPE_SUBMISSION_ERROR, [
'message' => 'Cannot download ZIP from ' . $zipUrl . ': ' . $e->getMessage(),
]);
if (isset($ziphandler)) {
fclose($ziphandler);
}
unlink($zipFile);
$submissionDownloadSucceeded = false;
}
} while ($tries <= 3 && !$submissionDownloadSucceeded);
}

if (isset($response, $ziphandler) && $submissionDownloadSucceeded) {
Expand Down
Loading