mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 00:32:29 -04:00
fix(files_version): use Storage::writeStream instead of deprecated streamCopy if possible
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
parent
01db539d0a
commit
0f69648d0a
1 changed files with 16 additions and 4 deletions
|
|
@ -33,6 +33,7 @@ use OCP\Files\NotFoundException;
|
|||
use OCP\Files\NotPermittedException;
|
||||
use OCP\Files\Search\ISearchBinaryOperator;
|
||||
use OCP\Files\Search\ISearchComparison;
|
||||
use OCP\Files\Storage\IWriteStreamStorage;
|
||||
use OCP\Files\StorageInvalidException;
|
||||
use OCP\Files\StorageNotAvailableException;
|
||||
use OCP\IURLGenerator;
|
||||
|
|
@ -421,10 +422,21 @@ class Storage {
|
|||
|| $storage2->instanceOfStorage(\OC\Files\ObjectStore\ObjectStoreStorage::class)
|
||||
) {
|
||||
$source = $storage1->fopen($internalPath1, 'r');
|
||||
$target = $storage2->fopen($internalPath2, 'w');
|
||||
[, $result] = Files::streamCopy($source, $target, true);
|
||||
fclose($source);
|
||||
fclose($target);
|
||||
$result = $source !== false;
|
||||
if ($result) {
|
||||
if ($storage2->instanceOfStorage(IWriteStreamStorage::class)) {
|
||||
/** @var IWriteStreamStorage $storage2 */
|
||||
$storage2->writeStream($internalPath2, $source);
|
||||
} else {
|
||||
$target = $storage2->fopen($internalPath2, 'w');
|
||||
$result = $target !== false;
|
||||
if ($target !== false) {
|
||||
[, $result] = Files::streamCopy($source, $target, true);
|
||||
fclose($target);
|
||||
}
|
||||
}
|
||||
fclose($source);
|
||||
}
|
||||
|
||||
if ($result !== false) {
|
||||
$storage1->unlink($internalPath1);
|
||||
|
|
|
|||
Loading…
Reference in a new issue