Skip to content

Commit

Permalink
Handle files with is_file instead of file_exists
Browse files Browse the repository at this point in the history
Should fix things like `fread(): read of 8192 bytes failed with errno=21 Is a directory`
  • Loading branch information
solracsf authored and backportbot[bot] committed Oct 23, 2021
1 parent 449b430 commit cd077bf
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/private/Files/Storage/Wrapper/Encryption.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ public function fopen($path, $mode) {
if ($this->util->isExcluded($fullPath) === false) {
$size = $unencryptedSize = 0;
$realFile = $this->util->stripPartialFileExtension($path);
$targetExists = $this->file_exists($realFile) || $this->file_exists($path);
$targetExists = $this->is_file($realFile) || $this->file_exists($path);
$targetIsEncrypted = false;
if ($targetExists) {
// in case the file exists we require the explicit module as
Expand Down Expand Up @@ -853,7 +853,7 @@ protected function getFullPath($path) {
*/
protected function readFirstBlock($path) {
$firstBlock = '';
if ($this->storage->file_exists($path)) {
if ($this->storage->is_file($path)) {
$handle = $this->storage->fopen($path, 'r');
$firstBlock = fread($handle, $this->util->getHeaderSize());
fclose($handle);
Expand All @@ -870,7 +870,7 @@ protected function readFirstBlock($path) {
protected function getHeaderSize($path) {
$headerSize = 0;
$realFile = $this->util->stripPartialFileExtension($path);
if ($this->storage->file_exists($realFile)) {
if ($this->storage->is_file($realFile)) {
$path = $realFile;
}
$firstBlock = $this->readFirstBlock($path);
Expand Down Expand Up @@ -918,7 +918,7 @@ protected function parseRawHeader($rawHeader) {
*/
protected function getHeader($path) {
$realFile = $this->util->stripPartialFileExtension($path);
$exists = $this->storage->file_exists($realFile);
$exists = $this->storage->is_file($realFile);
if ($exists) {
$path = $realFile;
}
Expand Down

0 comments on commit cd077bf

Please sign in to comment.