Skip to content

Commit

Permalink
cs fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SniperSister committed Jun 12, 2022
1 parent 79ebf4c commit 355addf
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions libraries/src/TUF/HttpFileFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class HttpFileFetcher implements RepoFileFetcherInterface
* The base URI for requests
*
* @var string|null
*
* @since __DEPLOY_VERSION__
*/
private $baseUri;

Expand Down Expand Up @@ -145,7 +147,8 @@ protected function fetchFile(string $url, int $maxBytes, array $options = []): P
// $maxBytes. This will only work with cURL, so we also verify the
// download size when request is finished.
$progress = function (int $expectedBytes, int $downloadedBytes) use ($url, $maxBytes) {
if ($expectedBytes > $maxBytes || $downloadedBytes > $maxBytes) {
if ($expectedBytes > $maxBytes || $downloadedBytes > $maxBytes)
{
throw new DownloadSizeException("$url exceeded $maxBytes bytes");
}
};
Expand All @@ -156,11 +159,13 @@ protected function fetchFile(string $url, int $maxBytes, array $options = []): P
$response = $this->client->get($this->baseUri . $url, $headers);
$response->getBody()->rewind();

if ($response->getStatusCode() === 404) {
if ($response->getStatusCode() === 404)
{
throw new RepoFileNotFound();
}

if ($response->getStatusCode() !== 200) {
if ($response->getStatusCode() !== 200)
{
throw new \RuntimeException(
"Invalid TUF repo response: " . $response->getBody()->getContents(),
$response->getStatusCode()
Expand All @@ -180,9 +185,12 @@ protected function fetchFile(string $url, int $maxBytes, array $options = []): P
*/
public function fetchMetadataIfExists(string $fileName, int $maxBytes): ?string
{
try {
try
{
return $this->fetchMetadata($fileName, $maxBytes)->wait();
} catch (RepoFileNotFound $exception) {
}
catch (RepoFileNotFound $exception)
{
return null;
}
}
Expand Down

0 comments on commit 355addf

Please sign in to comment.