diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2025-06-24 17:01:21 +0200 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2025-06-24 15:03:03 +0000 |
commit | 24afedcbf16e2272a58a3a6d436cd00eafd0a255 (patch) | |
tree | 5b23931778012cd3b2b3bb1514001c3820a5e245 | |
parent | 705a7975a54c6aeb4f6e3890c31c306f2c18f174 (diff) | |
download | nextcloud-server-backport/53665/stable31.tar.gz nextcloud-server-backport/53665/stable31.zip |
fix(encryption): Catch exceptions in encrypt-all command and continuebackport/53665/stable31
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
-rw-r--r-- | apps/encryption/lib/Crypto/EncryptAll.php | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/apps/encryption/lib/Crypto/EncryptAll.php b/apps/encryption/lib/Crypto/EncryptAll.php index 6dfa36e6e3d..6454c7d6e13 100644 --- a/apps/encryption/lib/Crypto/EncryptAll.php +++ b/apps/encryption/lib/Crypto/EncryptAll.php @@ -20,6 +20,7 @@ use OCP\L10N\IFactory; use OCP\Mail\Headers\AutoSubmitted; use OCP\Mail\IMailer; use OCP\Security\ISecureRandom; +use Psr\Log\LoggerInterface; use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Helper\QuestionHelper; use Symfony\Component\Console\Helper\Table; @@ -50,6 +51,7 @@ class EncryptAll { protected IFactory $l10nFactory, protected QuestionHelper $questionHelper, protected ISecureRandom $secureRandom, + protected LoggerInterface $logger, ) { // store one time passwords for the users $this->userPasswords = []; @@ -207,9 +209,22 @@ class EncryptAll { } else { $progress->setMessage("encrypt files for user $userCount: $path"); $progress->advance(); - if ($this->encryptFile($path) === false) { - $progress->setMessage("encrypt files for user $userCount: $path (already encrypted)"); + try { + if ($this->encryptFile($path) === false) { + $progress->setMessage("encrypt files for user $userCount: $path (already encrypted)"); + $progress->advance(); + } + } catch (\Exception $e) { + $progress->setMessage("Failed to encrypt path $path: " . $e->getMessage()); $progress->advance(); + $this->logger->error( + 'Failed to encrypt path {path}', + [ + 'user' => $uid, + 'path' => $path, + 'exception' => $e, + ] + ); } } } |