From 5d0fa12e1291addef1251fd2b1777f203fbf161b Mon Sep 17 00:00:00 2001
From: Bjoern Schiessle <bjoern@schiessle.org>
Date: Thu, 5 Jul 2018 16:57:48 +0200
Subject: [PATCH] allow to disable encryption

Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
---
 lib/private/Files/Storage/Wrapper/Encryption.php | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php
index 109de4c4e5c..42653b2d4a6 100644
--- a/lib/private/Files/Storage/Wrapper/Encryption.php
+++ b/lib/private/Files/Storage/Wrapper/Encryption.php
@@ -412,9 +412,13 @@ class Encryption extends Wrapper {
 					|| $mode === 'wb'
 					|| $mode === 'wb+'
 				) {
-					// don't overwrite encrypted files if encryption is not enabled
+					// if we update a encrypted file with a un-encrypted one we change the db flag
 					if ($targetIsEncrypted && $encryptionEnabled === false) {
-						throw new GenericEncryptionException('Tried to access encrypted file but encryption is not enabled');
+						$cache = $this->storage->getCache();
+						if ($cache) {
+							$entry = $cache->get($path);
+							$cache->update($entry->getId(), ['encrypted' => 0]);
+						}
 					}
 					if ($encryptionEnabled) {
 						// if $encryptionModuleId is empty, the default module will be used
-- 
GitLab