diff options
author | John Molakvoæ <skjnldsv@users.noreply.github.com> | 2021-09-07 12:52:08 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-07 12:52:08 +0300 |
commit | 00c2aa5dada374988f3ef08a0064a8ab9115ada2 (patch) | |
tree | 3c0a593a21cec190df143ce3fe21043e8ce64747 /lib | |
parent | 7dece11af05e7a2d41db919a8dee855f77ac915e (diff) | |
parent | bb092dd7cc711dadab7ee62e3e225c308725c160 (diff) |
Merge pull request #27406 from nextcloud/backport/24966/stable21
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Files/Storage/Wrapper/Encryption.php | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php index a7a915afad9..64c9b0a4a66 100644 --- a/lib/private/Files/Storage/Wrapper/Encryption.php +++ b/lib/private/Files/Storage/Wrapper/Encryption.php @@ -925,21 +925,20 @@ class Encryption extends Wrapper { $path = $realFile; } - $firstBlock = $this->readFirstBlock($path); - $result = $this->parseRawHeader($firstBlock); + $result = []; + + // first check if it is an encrypted file at all + // We would do query to filecache only if we know that entry in filecache exists + + $info = $this->getCache()->get($path); + if (isset($info['encrypted']) && $info['encrypted'] === true) { + $firstBlock = $this->readFirstBlock($path); + $result = $this->parseRawHeader($firstBlock); - // if the header doesn't contain a encryption module we check if it is a - // legacy file. If true, we add the default encryption module - if (!isset($result[Util::HEADER_ENCRYPTION_MODULE_KEY])) { - if (!empty($result)) { + // if the header doesn't contain a encryption module we check if it is a + // legacy file. If true, we add the default encryption module + if (!isset($result[Util::HEADER_ENCRYPTION_MODULE_KEY]) && (!empty($result) || $exists)) { $result[Util::HEADER_ENCRYPTION_MODULE_KEY] = 'OC_DEFAULT_MODULE'; - } elseif ($exists) { - // if the header was empty we have to check first if it is a encrypted file at all - // We would do query to filecache only if we know that entry in filecache exists - $info = $this->getCache()->get($path); - if (isset($info['encrypted']) && $info['encrypted'] === true) { - $result[Util::HEADER_ENCRYPTION_MODULE_KEY] = 'OC_DEFAULT_MODULE'; - } } } |