Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable21] Handle files with is_file instead of file_exists #29416

Merged
merged 3 commits into from
Oct 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -391,7 +391,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 @@ -855,7 +855,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 @@ -872,7 +872,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 @@ -920,7 +920,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
4 changes: 2 additions & 2 deletions tests/lib/Files/Storage/Wrapper/EncryptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ public function testGetHeader($path, $strippedPathExists, $strippedPath) {
$util->expects($this->once())->method('stripPartialFileExtension')
->with($path)->willReturn($strippedPath);
$sourceStorage->expects($this->once())
->method('file_exists')
->method('is_file')
->with($strippedPath)
->willReturn($strippedPathExists);

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

$sourceStorage->expects($this->once())
->method('file_exists')
->method('is_file')
->willReturn($exists);

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