diff options
author | blizzz <blizzz@arthur-schiwon.de> | 2022-06-24 12:33:18 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-24 12:33:18 +0300 |
commit | 60ad644f5089f27f9d7b4c59ddbe466119630a0c (patch) | |
tree | da7400ef8e845639160beb2cebdc5e7e44be9e3f | |
parent | d5c40fe4c1888ce65590a2a9527a7dfa50f3abea (diff) | |
parent | 61811108072f9e192274d18e72bf9be6a916eb9c (diff) |
Merge pull request #236 from nextcloud/fix/handle-encryption-errors
Handle encryption error
-rw-r--r-- | lib/Scanner/ScannerBase.php | 10 | ||||
-rw-r--r-- | tests/stub.phpstub | 5 |
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 { } |