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>
This commit is contained in:
Côme Chilliet 2025-09-02 17:48:01 +02:00 committed by Andy Scherzinger
parent feef3cfa7d
commit bccec549e5

View file

@ -337,7 +337,7 @@ class Encryption extends Wrapper {
}
// 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;
}
@ -585,7 +585,7 @@ class Encryption extends Wrapper {
bool $isRename,
bool $keepEncryptionVersion,
): void {
$isEncrypted = $this->encryptionManager->isEnabled() && $this->shouldEncrypt($targetInternalPath);
$isEncrypted = $this->shouldEncrypt($targetInternalPath);
$cacheInformation = [
'encrypted' => $isEncrypted,
];
@ -885,6 +885,9 @@ class Encryption extends Wrapper {
* 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) {