Skip to content

Commit

Permalink
Remove file from the cache before scanning. This will lead to the fil…
Browse files Browse the repository at this point in the history
…e not beeing available until the scan is done.
  • Loading branch information
ata-no-one committed Nov 25, 2024
1 parent 9483ff5 commit dabf475
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions lib/EventListener/FileEventsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,27 @@

use Exception;
use OC_Template;
use OCP\IAppConfig;
use OCA\GDataVaas\AppInfo\Application;
use OCA\Files_Versions\Versions\IVersionManager;
use OCA\GDataVaas\Exceptions\VirusFoundException;
use OCA\GDataVaas\Service\FileService;
use OCA\GDataVaas\Service\MailService;
use OCA\GDataVaas\Service\TagService;
use OCA\GDataVaas\Service\VerdictService;
use OCA\GDataVaas\Exceptions\VirusFoundException;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\Files\Events\Node\BeforeNodeWrittenEvent;
use OCP\Files\Events\Node\NodeWrittenEvent;
use OCP\Files\IMimeTypeLoader;
use OCP\Files\IRootFolder;
use OCP\IAppConfig;
use OCP\IConfig;
use OCP\IRequest;
use OCP\IUserSession;
use Psr\Log\LoggerInterface;
use Sabre\DAV\Server;
use OCA\GDataVaas\Service\MailService;

/** @template-implements IEventListener<BeforeNodeCopiedEvent|BeforeNodeDeletedEvent|BeforeNodeRenamedEvent|BeforeNodeTouchedEvent|BeforeNodeWrittenEvent|NodeCopiedEvent|NodeCreatedEvent|NodeDeletedEvent|NodeRenamedEvent|NodeTouchedEvent|NodeWrittenEvent> */
class FileEventsListener implements IEventListener {
public function __construct(
private IRootFolder $rootFolder,
private IVersionManager $versionManager,
private IMimeTypeLoader $mimeTypeLoader,
private IUserSession $userSession,
private LoggerInterface $logger,
private IConfig $config,
Expand All @@ -40,7 +34,7 @@ public function __construct(
private FileService $fileService,
private TagService $tagService,
private IAppConfig $appConfig,
private MailService $mailService
private MailService $mailService,
) {
}

Expand All @@ -51,6 +45,8 @@ public static function register(IRegistrationContext $context): void {
public function handle(Event $event): void {
if ($event instanceof NodeWrittenEvent) {
$node = $event->getNode();
$filesCache = $node->getStorage()->getCache();
$filesCache->remove($node->getId());
if ($node->getType() !== \OCP\Files\FileInfo::TYPE_FILE) {
return;
}
Expand Down

0 comments on commit dabf475

Please sign in to comment.