just pass the share instead of searching for it

This commit is contained in:
Robin Appelman 2015-08-05 15:41:29 +02:00
parent 085acaf6ba
commit 859da8f0b3
3 changed files with 11 additions and 23 deletions

View file

@ -60,7 +60,7 @@ class Shared_Cache extends Cache {
if ($target === false || $target === $this->storage->getMountPoint()) { if ($target === false || $target === $this->storage->getMountPoint()) {
$target = ''; $target = '';
} }
$source = \OC_Share_Backend_File::getSource($target, $this->storage->getMountPoint(), $this->storage->getItemType()); $source = \OC_Share_Backend_File::getSource($target, $this->storage->getShare());
if (isset($source['path']) && isset($source['fileOwner'])) { if (isset($source['path']) && isset($source['fileOwner'])) {
\OC\Files\Filesystem::initMountPoints($source['fileOwner']); \OC\Files\Filesystem::initMountPoints($source['fileOwner']);
$mounts = \OC\Files\Filesystem::getMountByNumericId($source['storage']); $mounts = \OC\Files\Filesystem::getMountByNumericId($source['storage']);
@ -242,7 +242,7 @@ class Shared_Cache extends Cache {
*/ */
protected function getMoveInfo($path) { protected function getMoveInfo($path) {
$cache = $this->getSourceCache($path); $cache = $this->getSourceCache($path);
$file = \OC_Share_Backend_File::getSource($path, $this->storage->getMountPoint(), $this->storage->getItemType()); $file = \OC_Share_Backend_File::getSource($path, $this->storage->getShare());
return [$cache->getNumericStorageId(), $file['path']]; return [$cache->getNumericStorageId(), $file['path']];
} }

View file

@ -206,27 +206,15 @@ class OC_Share_Backend_File implements OCP\Share_Backend_File_Dependent {
/** /**
* @param string $target * @param string $target
* @param string $mountPoint * @param array $share
* @param string $itemType
* @return array|false source item * @return array|false source item
*/ */
public static function getSource($target, $mountPoint, $itemType) { public static function getSource($target, $share) {
if ($itemType === 'folder') { if ($share['item_type'] === 'folder' && $target !== '') {
$source = \OCP\Share::getItemSharedWith('folder', $mountPoint, \OC_Share_Backend_File::FORMAT_SHARED_STORAGE); // note: in case of ext storage mount points the path might be empty
if ($source && $target !== '') { // which would cause a leading slash to appear
// note: in case of ext storage mount points the path might be empty $share['path'] = ltrim($share['path'] . '/' . $target, '/');
// which would cause a leading slash to appear
$source['path'] = ltrim($source['path'] . '/' . $target, '/');
}
} else {
$source = \OCP\Share::getItemSharedWith('file', $mountPoint, \OC_Share_Backend_File::FORMAT_SHARED_STORAGE);
} }
if ($source) { return self::resolveReshares($share);
return self::resolveReshares($source);
}
\OCP\Util::writeLog('files_sharing', 'File source not found for: '.$target, \OCP\Util::DEBUG);
return false;
} }
} }

View file

@ -83,14 +83,14 @@ class Shared extends \OC\Files\Storage\Common implements ISharedStorage {
if (!isset($this->files[$target])) { if (!isset($this->files[$target])) {
// Check for partial files // Check for partial files
if (pathinfo($target, PATHINFO_EXTENSION) === 'part') { if (pathinfo($target, PATHINFO_EXTENSION) === 'part') {
$source = \OC_Share_Backend_File::getSource(substr($target, 0, -5), $this->getMountPoint(), $this->getItemType()); $source = \OC_Share_Backend_File::getSource(substr($target, 0, -5), $this->getShare());
if ($source) { if ($source) {
$source['path'] .= '.part'; $source['path'] .= '.part';
// All partial files have delete permission // All partial files have delete permission
$source['permissions'] |= \OCP\Constants::PERMISSION_DELETE; $source['permissions'] |= \OCP\Constants::PERMISSION_DELETE;
} }
} else { } else {
$source = \OC_Share_Backend_File::getSource($target, $this->getMountPoint(), $this->getItemType()); $source = \OC_Share_Backend_File::getSource($target, $this->getShare());
} }
$this->files[$target] = $source; $this->files[$target] = $source;
} }