Properly handle result when copying with failure and throw in tests

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2021-01-05 09:12:11 +01:00
parent ee842f1c43
commit 98560c80ea
No known key found for this signature in database
GPG Key ID: 4C614C6ED2CDE6DF
2 changed files with 4 additions and 3 deletions

View File

@ -689,9 +689,9 @@ abstract class Common implements Storage, ILockingStorage, IWriteStreamStorage {
$result = $this->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath, true);
if ($result) {
if ($sourceStorage->is_dir($sourceInternalPath)) {
$result &= $sourceStorage->rmdir($sourceInternalPath);
$result = $result && $sourceStorage->rmdir($sourceInternalPath);
} else {
$result &= $sourceStorage->unlink($sourceInternalPath);
$result = $result && $sourceStorage->unlink($sourceInternalPath);
}
}
return $result;

View File

@ -17,6 +17,7 @@ use OC\Files\View;
use OCP\Constants;
use OCP\Files\Config\IMountProvider;
use OCP\Files\FileInfo;
use OCP\Files\GenericFileException;
use OCP\Files\Storage\IStorage;
use OCP\Lock\ILockingProvider;
use OCP\Lock\LockedException;
@ -1167,7 +1168,7 @@ class ViewTest extends \Test\TestCase {
->getMock();
$storage2->method('writeStream')
->willReturn(0);
->willThrowException(new GenericFileException("Failed to copy stream"));
$storage1->mkdir('sub');
$storage1->file_put_contents('foo.txt', '0123456789ABCDEFGH');