Skip to content
Prev Previous commit
Next Next commit
fix(encryption): Take encryption enabled status into account
shouldEncrypt now returns false for all paths if encryption is disabled.

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
  • Loading branch information
come-nc authored and backportbot[bot] committed Sep 11, 2025
commit 826fe17b8aee313e0f5c04358d24b6b3f59c13ca
7 changes: 5 additions & 2 deletions lib/private/Files/Storage/Wrapper/Encryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ public function fopen(string $path, string $mode) {
}

// encryption disabled on write of new file and write to existing unencrypted file -> don't encrypt
if (!$encryptionEnabled || !$this->shouldEncrypt($path)) {
if (!$this->shouldEncrypt($path)) {
if (!$targetExists || !$targetIsEncrypted) {
$shouldEncrypt = false;
}
Expand Down Expand Up @@ -573,7 +573,7 @@ private function updateEncryptedVersion(
bool $isRename,
bool $keepEncryptionVersion,
): void {
$isEncrypted = $this->encryptionManager->isEnabled() && $this->shouldEncrypt($targetInternalPath);
$isEncrypted = $this->shouldEncrypt($targetInternalPath);
$cacheInformation = [
'encrypted' => $isEncrypted,
];
Expand Down Expand Up @@ -873,6 +873,9 @@ protected function isVersion(string $path): bool {
* check if the given storage should be encrypted or not
*/
public function shouldEncrypt(string $path): bool {
if (!$this->encryptionManager->isEnabled()) {
return false;
}
$fullPath = $this->getFullPath($path);
$mountPointConfig = $this->mount->getOption('encrypt', true);
if ($mountPointConfig === false) {
Expand Down