Merge pull request #16284 from owncloud/shared-storage-view

dont go trough the view when renaming/copying on shared storages
This commit is contained in:
Lukas Reschke 2015-05-13 10:37:04 +02:00
commit 5941e826b8
1 changed files with 21 additions and 20 deletions

View File

@ -31,7 +31,6 @@ namespace OC\Files\Storage;
use OC\Files\Cache\ChangePropagator; use OC\Files\Cache\ChangePropagator;
use OC\Files\Filesystem; use OC\Files\Filesystem;
use OC\Files\View;
use OCA\Files_Sharing\ISharedStorage; use OCA\Files_Sharing\ISharedStorage;
use OCA\Files_Sharing\Propagator; use OCA\Files_Sharing\Propagator;
use OCA\Files_Sharing\SharedMount; use OCA\Files_Sharing\SharedMount;
@ -327,30 +326,32 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage {
} }
} }
// for part files we need to ask for the owner and path from the parent directory because
// the file cache doesn't return any results for part files /**
if ($isPartFile) { * @var \OC\Files\Storage\Storage $sourceStorage
list($user1, $path1) = \OCA\Files_Sharing\Helper::getUidAndFilename($pathinfo['dirname']); */
$path1 = $path1 . '/' . $pathinfo['basename']; list($sourceStorage, $sourceInternalPath) = $this->resolvePath($path1);
} else { /**
list($user1, $path1) = \OCA\Files_Sharing\Helper::getUidAndFilename($relPath1); * @var \OC\Files\Storage\Storage $targetStorage
} */
$targetFilename = basename($relPath2); list($targetStorage, $targetInternalPath) = $this->resolvePath($path2);
list($user2, $path2) = \OCA\Files_Sharing\Helper::getUidAndFilename(dirname($relPath2));
$rootView = new \OC\Files\View(''); return $targetStorage->moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
$rootView->getUpdater()->disable(); // dont update the cache here
$result = $rootView->rename('/' . $user1 . '/files/' . $path1, '/' . $user2 . '/files/' . $path2 . '/' . $targetFilename);
$rootView->getUpdater()->enable();
return $result;
} }
public function copy($path1, $path2) { public function copy($path1, $path2) {
// Copy the file if CREATE permission is granted // Copy the file if CREATE permission is granted
if ($this->isCreatable(dirname($path2))) { if ($this->isCreatable(dirname($path2))) {
$oldSource = $this->getSourcePath($path1); /**
$newSource = $this->getSourcePath(dirname($path2)) . '/' . basename($path2); * @var \OC\Files\Storage\Storage $sourceStorage
$rootView = new \OC\Files\View(''); */
return $rootView->copy($oldSource, $newSource); list($sourceStorage, $sourceInternalPath) = $this->resolvePath($path1);
/**
* @var \OC\Files\Storage\Storage $targetStorage
*/
list($targetStorage, $targetInternalPath) = $this->resolvePath($path2);
return $targetStorage->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
} }
return false; return false;
} }