diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2025-07-03 11:02:06 +0200 |
---|---|---|
committer | Côme Chilliet <91878298+come-nc@users.noreply.github.com> | 2025-07-03 15:19:34 +0200 |
commit | 4427050f840afee97a0de8d5e58d8ca5f5eb6196 (patch) | |
tree | 9289fa98b47323bc0dc0f1c96f8c9a84bc229ef6 /apps/encryption | |
parent | 58e8626f5f331b5e28ea8658763493cac4dcf70c (diff) | |
download | nextcloud-server-fix/catch-exception-in-encrypt-all.tar.gz nextcloud-server-fix/catch-exception-in-encrypt-all.zip |
fix(encryption): Correctly handle file opening and copying failuresfix/catch-exception-in-encrypt-all
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps/encryption')
-rw-r--r-- | apps/encryption/lib/Crypto/EncryptAll.php | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/apps/encryption/lib/Crypto/EncryptAll.php b/apps/encryption/lib/Crypto/EncryptAll.php index 6454c7d6e13..d9db616e6f1 100644 --- a/apps/encryption/lib/Crypto/EncryptAll.php +++ b/apps/encryption/lib/Crypto/EncryptAll.php @@ -249,7 +249,14 @@ class EncryptAll { $target = $path . '.encrypted.' . time(); try { - $this->rootView->copy($source, $target); + $copySuccess = $this->rootView->copy($source, $target); + if ($copySuccess === false) { + /* Copy failed, abort */ + if ($this->rootView->file_exists($target)) { + $this->rootView->unlink($target); + } + throw new \Exception('Copy failed for ' . $source); + } $this->rootView->rename($target, $source); } catch (DecryptionFailedException $e) { if ($this->rootView->file_exists($target)) { |