Skip to content

Commit

Permalink
fix(common/storage): If 404 the file is missing (otherwise throws an …
Browse files Browse the repository at this point in the history
…error) in HTTP storage service (#1077)
  • Loading branch information
theus77 authored Nov 25, 2024
1 parent dc4d7fe commit 9155e9a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions EMS/common-bundle/src/Storage/Service/HttpStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use GuzzleHttp\Exception\GuzzleException;
use Psr\Http\Message\StreamInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

class HttpStorage extends AbstractUrlStorage
Expand Down Expand Up @@ -124,9 +125,12 @@ public function finalizeUpload(string $hash): bool
public function head(string $hash): bool
{
try {
return 200 === $this->getClient()->head($this->getUrl.$hash)->getStatusCode();
} catch (\Throwable) {
throw new NotFoundHttpException($hash);
return Response::HTTP_OK === $this->getClient()->head($this->getUrl.$hash)->getStatusCode();
} catch (\Throwable $e) {
if (Response::HTTP_NOT_FOUND === $e->getCode()) {
return false;
}
throw $e;
}
}

Expand Down

0 comments on commit 9155e9a

Please sign in to comment.