Commit 9a3815cc authored by Predhumeau Manon's avatar Predhumeau Manon Committed by Guillaume Perréal
Browse files

Corrections in virusListener code

parent 66966364
...@@ -33,15 +33,16 @@ class VirusScannerListener ...@@ -33,15 +33,16 @@ class VirusScannerListener
/** /**
* @param FileUploadCompleteEvent $event * @param FileUploadCompleteEvent $event
* @throws ConnectionException
*/ */
public function onFileUploadCompleted(FileUploadCompleteEvent $event) public function onFileUploadCompleted(FileUploadCompleteEvent $event)
{ {
$this->client = $this->getClient(); $client = $this->getClient();
$file = $event->getUploadedFile(); $file = $event->getUploadedFile();
$path = $file->getLocalPath(); $path = $file->getLocalPath();
$result = $this->client->scanFile($path); $result = $client->scanFile($path);
$hasVirus = $result['status'] === Client::RESULT_FOUND; $hasVirus = $result['status'] === Client::RESULT_FOUND;
$meta = $file->getMetadata(); $meta = $file->getMetadata();
...@@ -65,13 +66,8 @@ class VirusScannerListener ...@@ -65,13 +66,8 @@ class VirusScannerListener
*/ */
private function getClient(): Client private function getClient(): Client
{ {
try { // Check clamd server's state
// Check clamd server's state $this->client->ping();
$this->client->ping(); return $this->client;
return $this->client;
} catch (ConnectionException $connectionException) {
throw $connectionException;
}
} }
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment