From ab3f116b0afe2fb2ba1ca4bbce5a1c5224bea8c1 Mon Sep 17 00:00:00 2001 From: PT-ATA No One Date: Wed, 6 Nov 2024 10:11:53 +0000 Subject: [PATCH] Revert "WIP try with explicit scan in CacheEntryInsertedEvent" This reverts commit baeb2808d4d51a4440333c4e819ba79e2f23f5f7. --- lib/AppInfo/Application.php | 5 +-- lib/Listener/CacheEntryInsertedListener.php | 49 --------------------- 2 files changed, 1 insertion(+), 53 deletions(-) delete mode 100644 lib/Listener/CacheEntryInsertedListener.php diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 1eb0efeb..29aff2de 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -8,7 +8,6 @@ use OCA\GDataVaas\AvirWrapper; use OCA\GDataVaas\CacheEntryListener; use OCA\GDataVaas\Db\DbFileMapper; -use OCA\GDataVaas\Listener\CacheEntryInsertedListener; use OCA\GDataVaas\Service\MailService; use OCA\GDataVaas\Service\TagService; use OCA\GDataVaas\Service\VerdictService; @@ -21,7 +20,6 @@ use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCP\Collaboration\Resources\LoadAdditionalScriptsEvent; use OCP\EventDispatcher\IEventDispatcher; -use OCP\Files\Cache\CacheEntryInsertedEvent; use OCP\Files\IHomeStorage; use OCP\Files\Storage\IStorage; use OCP\IAppConfig; @@ -48,8 +46,7 @@ public function __construct() { $eventDispatcher->addListener(LoadAdditionalScriptsEvent::class, function () { Util::addScript(self::APP_ID, 'gdatavaas-files-action'); }); - //$eventDispatcher->addServiceListener(CacheEntryInsertedEvent::class, CacheEntryInsertedListener::class); - } + } /** * Load the composer autoloader if it exists diff --git a/lib/Listener/CacheEntryInsertedListener.php b/lib/Listener/CacheEntryInsertedListener.php deleted file mode 100644 index 3ccaa2f0..00000000 --- a/lib/Listener/CacheEntryInsertedListener.php +++ /dev/null @@ -1,49 +0,0 @@ -logger = $logger; - $this->verdictService = $verdictService; - } - - public function handle(Event $event): void - { - if (!($event instanceof CacheEntryInsertedEvent)) { - return; - } - - $this->logger->info('Cache entry inserted: ' . $event->getPath()); - - $fileId = $event->getFileId(); - try { - $verdict = $this->verdictService->scanFileById($fileId); - // Delete file if malicious - } catch (EntityTooLargeException|NotFoundException|NotPermittedException|FileDoesNotExistException|InvalidSha256Exception|TimeoutException|UploadFailedException|VaasAuthenticationException $e) { - $this->logger->error($e->getMessage()); - } catch (Exception $e) { - $this->logger->error('An unexpected error occurred while scanning file ' . $fileId . ' with GData VaaS. Please check the logs for more information and contact your administrator: ' . $e->getMessage()); - } - } -} \ No newline at end of file