Skip to content

Commit e250aef

Browse files
authored
Merge pull request #29416 from nextcloud/backport/27440/stable21
[stable21] Handle files with `is_file` instead of `file_exists`
2 parents 81b3e65 + 8610099 commit e250aef

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lib/private/Files/Storage/Wrapper/Encryption.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ public function fopen($path, $mode) {
391391
if ($this->util->isExcluded($fullPath) === false) {
392392
$size = $unencryptedSize = 0;
393393
$realFile = $this->util->stripPartialFileExtension($path);
394-
$targetExists = $this->file_exists($realFile) || $this->file_exists($path);
394+
$targetExists = $this->is_file($realFile) || $this->file_exists($path);
395395
$targetIsEncrypted = false;
396396
if ($targetExists) {
397397
// in case the file exists we require the explicit module as
@@ -855,7 +855,7 @@ protected function getFullPath($path) {
855855
*/
856856
protected function readFirstBlock($path) {
857857
$firstBlock = '';
858-
if ($this->storage->file_exists($path)) {
858+
if ($this->storage->is_file($path)) {
859859
$handle = $this->storage->fopen($path, 'r');
860860
$firstBlock = fread($handle, $this->util->getHeaderSize());
861861
fclose($handle);
@@ -872,7 +872,7 @@ protected function readFirstBlock($path) {
872872
protected function getHeaderSize($path) {
873873
$headerSize = 0;
874874
$realFile = $this->util->stripPartialFileExtension($path);
875-
if ($this->storage->file_exists($realFile)) {
875+
if ($this->storage->is_file($realFile)) {
876876
$path = $realFile;
877877
}
878878
$firstBlock = $this->readFirstBlock($path);
@@ -920,7 +920,7 @@ protected function parseRawHeader($rawHeader) {
920920
*/
921921
protected function getHeader($path) {
922922
$realFile = $this->util->stripPartialFileExtension($path);
923-
$exists = $this->storage->file_exists($realFile);
923+
$exists = $this->storage->is_file($realFile);
924924
if ($exists) {
925925
$path = $realFile;
926926
}

tests/lib/Files/Storage/Wrapper/EncryptionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ public function testGetHeader($path, $strippedPathExists, $strippedPath) {
624624
$util->expects($this->once())->method('stripPartialFileExtension')
625625
->with($path)->willReturn($strippedPath);
626626
$sourceStorage->expects($this->once())
627-
->method('file_exists')
627+
->method('is_file')
628628
->with($strippedPath)
629629
->willReturn($strippedPathExists);
630630

@@ -652,7 +652,7 @@ public function testGetHeaderAddLegacyModule($header, $isEncrypted, $exists, $ex
652652
->disableOriginalConstructor()->getMock();
653653

654654
$sourceStorage->expects($this->once())
655-
->method('file_exists')
655+
->method('is_file')
656656
->willReturn($exists);
657657

658658
$util = $this->getMockBuilder('\OC\Encryption\Util')

0 commit comments

Comments
 (0)