summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2021-04-06 13:43:55 +0200
committerGitHub <noreply@github.com>2021-04-06 13:43:55 +0200
commit90386ff92067b37cf24bcb2b6de74a0821feafca (patch)
treed5cb5bd03d0d2420b2f1fd792736e7bc2182e2e8 /lib
parent45e63c949c31499bfd601bfe4946b590f38e2cc6 (diff)
parent3a1444ee71c3ed53f8d3f5ea749b4531c3940e4b (diff)
downloadnextcloud-server-90386ff92067b37cf24bcb2b6de74a0821feafca.tar.gz
nextcloud-server-90386ff92067b37cf24bcb2b6de74a0821feafca.zip
Merge pull request #26399 from nextcloud/backport/26061/stable20
[stable20] Log and continue when failing to update encryption keys during for individual files
Diffstat (limited to 'lib')
-rw-r--r--lib/private/Encryption/EncryptionWrapper.php2
-rw-r--r--lib/private/Encryption/HookManager.php2
-rw-r--r--lib/private/Encryption/Update.php31
3 files changed, 23 insertions, 12 deletions
diff --git a/lib/private/Encryption/EncryptionWrapper.php b/lib/private/Encryption/EncryptionWrapper.php
index edbdc692b45..09d8435f163 100644
--- a/lib/private/Encryption/EncryptionWrapper.php
+++ b/lib/private/Encryption/EncryptionWrapper.php
@@ -31,6 +31,7 @@ use OC\Memcache\ArrayCache;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\Storage;
use OCP\ILogger;
+use Psr\Log\LoggerInterface;
/**
* Class EncryptionWrapper
@@ -100,6 +101,7 @@ class EncryptionWrapper {
Filesystem::getMountManager(),
$this->manager,
$fileHelper,
+ \OC::$server->get(LoggerInterface::class),
$uid
);
return new Encryption(
diff --git a/lib/private/Encryption/HookManager.php b/lib/private/Encryption/HookManager.php
index 8ddd506b691..16d45556b2f 100644
--- a/lib/private/Encryption/HookManager.php
+++ b/lib/private/Encryption/HookManager.php
@@ -25,6 +25,7 @@ namespace OC\Encryption;
use OC\Files\Filesystem;
use OC\Files\View;
+use Psr\Log\LoggerInterface;
class HookManager {
/**
@@ -67,6 +68,7 @@ class HookManager {
Filesystem::getMountManager(),
\OC::$server->getEncryptionManager(),
\OC::$server->getEncryptionFilesHelper(),
+ \OC::$server->get(LoggerInterface::class),
$uid
);
}
diff --git a/lib/private/Encryption/Update.php b/lib/private/Encryption/Update.php
index beb76a223b7..214cbaac686 100644
--- a/lib/private/Encryption/Update.php
+++ b/lib/private/Encryption/Update.php
@@ -26,40 +26,40 @@
namespace OC\Encryption;
+use InvalidArgumentException;
use OC\Files\Filesystem;
use OC\Files\Mount;
use OC\Files\View;
+use OCP\Encryption\Exceptions\GenericEncryptionException;
+use Psr\Log\LoggerInterface;
/**
* update encrypted files, e.g. because a file was shared
*/
class Update {
- /** @var \OC\Files\View */
+ /** @var View */
protected $view;
- /** @var \OC\Encryption\Util */
+ /** @var Util */
protected $util;
/** @var \OC\Files\Mount\Manager */
protected $mountManager;
- /** @var \OC\Encryption\Manager */
+ /** @var Manager */
protected $encryptionManager;
/** @var string */
protected $uid;
- /** @var \OC\Encryption\File */
+ /** @var File */
protected $file;
+ /** @var LoggerInterface */
+ protected $logger;
+
/**
- *
- * @param \OC\Files\View $view
- * @param \OC\Encryption\Util $util
- * @param \OC\Files\Mount\Manager $mountManager
- * @param \OC\Encryption\Manager $encryptionManager
- * @param \OC\Encryption\File $file
* @param string $uid
*/
public function __construct(
@@ -68,6 +68,7 @@ class Update {
Mount\Manager $mountManager,
Manager $encryptionManager,
File $file,
+ LoggerInterface $logger,
$uid
) {
$this->view = $view;
@@ -75,6 +76,7 @@ class Update {
$this->mountManager = $mountManager;
$this->encryptionManager = $encryptionManager;
$this->file = $file;
+ $this->logger = $logger;
$this->uid = $uid;
}
@@ -155,7 +157,7 @@ class Update {
$view = new View('/' . $owner . '/files');
$path = $view->getPath($info->getId());
if ($path === null) {
- throw new \InvalidArgumentException('No file found for ' . $info->getId());
+ throw new InvalidArgumentException('No file found for ' . $info->getId());
}
return [$owner, $path];
@@ -187,7 +189,12 @@ class Update {
foreach ($allFiles as $file) {
$usersSharing = $this->file->getAccessList($file);
- $encryptionModule->update($file, $this->uid, $usersSharing);
+ try {
+ $encryptionModule->update($file, $this->uid, $usersSharing);
+ } catch (GenericEncryptionException $e) {
+ // If the update of an individual file fails e.g. due to a corrupt key we should continue the operation and just log the failure
+ $this->logger->error('Failed to update encryption module for ' . $this->uid . ' ' . $file, [ 'exception' => $e ]);
+ }
}
}
}