From 9a3815cc2b7268329b7fbb01fe69345153e35f79 Mon Sep 17 00:00:00 2001 From: Predhumeau Manon <manon.predhumeau@irstea.fr> Date: Fri, 20 Oct 2017 08:53:36 +0200 Subject: [PATCH] Corrections in virusListener code --- Listener/VirusScannerListener.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Listener/VirusScannerListener.php b/Listener/VirusScannerListener.php index 47c0e81f..f4b49a9d 100644 --- a/Listener/VirusScannerListener.php +++ b/Listener/VirusScannerListener.php @@ -33,15 +33,16 @@ class VirusScannerListener /** * @param FileUploadCompleteEvent $event + * @throws ConnectionException */ public function onFileUploadCompleted(FileUploadCompleteEvent $event) { - $this->client = $this->getClient(); + $client = $this->getClient(); $file = $event->getUploadedFile(); $path = $file->getLocalPath(); - $result = $this->client->scanFile($path); + $result = $client->scanFile($path); $hasVirus = $result['status'] === Client::RESULT_FOUND; $meta = $file->getMetadata(); @@ -65,13 +66,8 @@ class VirusScannerListener */ private function getClient(): Client { - try { - // Check clamd server's state - $this->client->ping(); - return $this->client; - - } catch (ConnectionException $connectionException) { - throw $connectionException; - } + // Check clamd server's state + $this->client->ping(); + return $this->client; } } -- GitLab