hopleus 2 weeks ago committed by GitHub
commit 81e01bb1bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -617,6 +617,25 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil
return parent::copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
}
public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath)
{
$result = parent::moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
if ($result) {
$sourceCache = $sourceStorage->getCache();
$targetCache = $this->getCache();
$sourceEntry = $sourceCache->get($sourceInternalPath);
$targetEntry = $targetCache->get($targetInternalPath);
if ($sourceEntry && $targetEntry) {
$this->renameAfterMove($sourceEntry, $targetEntry);
}
}
return $result;
}
public function copy($source, $target) {
$source = $this->normalizePath($source);
$target = $this->normalizePath($target);
@ -675,6 +694,24 @@ class ObjectStoreStorage extends \OC\Files\Storage\Common implements IChunkedFil
}
}
private function renameAfterMove(ICacheEntry $sourceEntry, ICacheEntry $targetEntry): void
{
$sourceUrn = $this->getURN($sourceEntry->getId());
$targetUrn = $this->getURN($targetEntry->getId());
try {
$this->objectStore->copyObject($targetUrn, $sourceUrn);
} catch (\Exception $e) {
throw $e;
}
try {
$this->objectStore->deleteObject($targetUrn);
} catch (\Exception $e) {
throw $e;
}
}
public function startChunkedWrite(string $targetPath): string {
if (!$this->objectStore instanceof IObjectStoreMultiPartUpload) {
throw new GenericFileException('Object store does not support multipart upload');

Loading…
Cancel
Save