Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/files_antivirus.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-06-23 00:01:14 +0300
committerCarl Schwan <carl@carlschwan.eu>2022-06-23 18:47:05 +0300
commit61811108072f9e192274d18e72bf9be6a916eb9c (patch)
tree33db3e26418e5f348a06ee0b1b0bd9d5eebdd122
parent0ad79deb19a680bd77454c7076cc5275cbdeb322 (diff)
Handle encryption errorfix/handle-encryption-errors
When we can't read a file due to some encryption issue, just abort instead of trying again and againt to read it. Signed-off-by: Carl Schwan <carl@carlschwan.eu>
-rw-r--r--lib/Scanner/ScannerBase.php10
-rw-r--r--tests/stub.phpstub5
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/Scanner/ScannerBase.php b/lib/Scanner/ScannerBase.php
index 65d1ae3..1e93572 100644
--- a/lib/Scanner/ScannerBase.php
+++ b/lib/Scanner/ScannerBase.php
@@ -111,8 +111,14 @@ abstract class ScannerBase implements IScanner {
public function scan(Item $item): Status {
$this->initScanner();
- while (false !== ($chunk = $item->fread())) {
- $this->writeChunk($chunk);
+ try {
+ while (false !== ($chunk = $item->fread())) {
+ $this->writeChunk($chunk);
+ }
+ } catch (\OCP\Encryption\Exceptions\GenericEncryptionException $e) {
+ // We can't read the file, ignore
+ $this->status->setNumericStatus(Status::SCANRESULT_CLEAN);
+ return $this->getStatus();
}
$this->shutdownScanner();
diff --git a/tests/stub.phpstub b/tests/stub.phpstub
index 2a961dd..8d25d21 100644
--- a/tests/stub.phpstub
+++ b/tests/stub.phpstub
@@ -40,6 +40,11 @@ namespace {
}
}
+namespace OC {
+ class HintException extends \Exception {
+ }
+}
+
namespace OC\Hooks {
class Emitter {
}