use returned file id for object store copy

Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
Robin Appelman 2021-03-08 18:50:33 +01:00 committed by backportbot[bot]
parent aaa4c071ed
commit 20ab946c3f
1 changed files with 6 additions and 6 deletions

View File

@ -32,6 +32,7 @@ namespace OC\Files\ObjectStore;
use Icewind\Streams\CallbackWrapper;
use Icewind\Streams\CountWrapper;
use Icewind\Streams\IteratorDirectory;
use OC\Files\Cache\Cache;
use OC\Files\Cache\CacheEntry;
use OC\Files\Storage\PolyFill\CopyDirectory;
use OCP\Files\Cache\ICacheEntry;
@ -566,14 +567,13 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common {
$sourceUrn = $this->getURN($sourceEntry->getId());
$cache->copyFromCache($cache, $sourceEntry, $to);
$targetEntry = $cache->get($to);
if (!$targetEntry) {
throw new \Exception('Target not in cache after copy');
if (!$cache instanceof Cache) {
throw new \Exception("Invalid source cache for object store copy");
}
$targetUrn = $this->getURN($targetEntry->getId());
$targetId = $cache->copyFromCache($cache, $sourceEntry, $to);
$targetUrn = $this->getURN($targetId);
try {
$this->objectStore->copyObject($sourceUrn, $targetUrn);