mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 00:32:29 -04:00
Merge pull request #54628 from nextcloud/backport/54607/stable31
[stable31] fix(encryption): Fix TypeError when trying to decrypt unencrypted file
This commit is contained in:
commit
40236a5665
2 changed files with 7 additions and 2 deletions
|
|
@ -671,6 +671,8 @@ class Encryption extends Wrapper {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
$source = false;
|
||||
$target = false;
|
||||
try {
|
||||
$source = $sourceStorage->fopen($sourceInternalPath, 'r');
|
||||
$target = $this->fopen($targetInternalPath, 'w');
|
||||
|
|
@ -680,10 +682,10 @@ class Encryption extends Wrapper {
|
|||
[, $result] = \OC_Helper::streamCopy($source, $target);
|
||||
}
|
||||
} finally {
|
||||
if (isset($source) && $source !== false) {
|
||||
if ($source !== false) {
|
||||
fclose($source);
|
||||
}
|
||||
if (isset($target) && $target !== false) {
|
||||
if ($target !== false) {
|
||||
fclose($target);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1185,6 +1185,9 @@ class ViewTest extends \Test\TestCase {
|
|||
$storage2->method('writeStream')
|
||||
->willThrowException(new GenericFileException('Failed to copy stream'));
|
||||
|
||||
$storage2->method('fopen')
|
||||
->willReturn(false);
|
||||
|
||||
$storage1->mkdir('sub');
|
||||
$storage1->file_put_contents('foo.txt', '0123456789ABCDEFGH');
|
||||
$storage1->mkdir('dirtomove');
|
||||
|
|
|
|||
Loading…
Reference in a new issue