Skip to content

Commit

Permalink
Merge pull request #298 from nextcloud/remove-invalid-items
Browse files Browse the repository at this point in the history
remove checked items for non-files
  • Loading branch information
icewind1991 authored Oct 26, 2023
2 parents 850bf58 + b2ef305 commit 736857f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
This application inspects files that are uploaded to Nextcloud for viruses before they are written to the Nextcloud storage. If a file is identified as a virus, it is either logged or not uploaded to the server. The application relies on the underlying ClamAV virus scanning engine, which the admin points Nextcloud to when configuring the application. Alternatively, a Kaspersky Scan Engine can be configured, which has to run on a separate server.
For this app to be effective, the ClamAV virus definitions should be kept up to date. Also note that enabling this app will impact system performance as additional processing is required for every upload. More information is available in the Antivirus documentation.
]]></description>
<version>5.2.2</version>
<version>5.2.3</version>
<licence>agpl</licence>

<author>Manuel Delgado</author>
Expand Down
9 changes: 9 additions & 0 deletions lib/BackgroundJob/BackgroundScanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ private function processFiles(iterable $fileIds): int {
$count++;
} else {
$this->logger->info('Tried to scan non file');
$this->deleteFileCheckTime($fileId);
}
} catch (\Exception $e) {
$this->logger->error(__METHOD__ . ', exception: ' . $e->getMessage(), ['app' => 'files_antivirus', 'exception' => $e]);
Expand Down Expand Up @@ -264,6 +265,14 @@ public function getOutdatedFiles() {
}
}

public function deleteFileCheckTime(int $fileId): void {
$query = $this->db->getQueryBuilder();
$query->delete('files_antivirus')
->where($query->expr()->eq('fileid', $query->createNamedParameter($fileId)));

$result = $query->executeStatement();
}

protected function scanOneFile(File $file): void {
$this->logger->debug('Scanning file with fileid: ' . $file->getId());
$this->eventDispatcher->dispatchTyped(new BeforeBackgroundScanEvent($file));
Expand Down

0 comments on commit 736857f

Please sign in to comment.