avoid fread on directories and unencrypted files
Reworking the logic in order to first check the filecache and only then reading the fileheader. This in order to solve #21578.
This commit is contained in:
parent
39c67d9868
commit
81e3ae4753
|
@ -929,6 +929,13 @@ class Encryption extends Wrapper {
|
|||
$path = $realFile;
|
||||
}
|
||||
|
||||
$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);
|
||||
|
||||
|
@ -938,10 +945,6 @@ class Encryption extends Wrapper {
|
|||
if (!empty($result)) {
|
||||
$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';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue