Merge pull request #17225 from owncloud/fix_12106

if it is a mount point we need to get the path from the mount manager
This commit is contained in:
Björn Schießle 2015-06-30 16:40:57 +02:00
commit 2c1b0f9a66
1 changed files with 19 additions and 3 deletions

View File

@ -372,6 +372,22 @@ class Share extends Constants {
if ($fileDependent && !self::isFileReachable($row['path'], $row['storage_id'])) { if ($fileDependent && !self::isFileReachable($row['path'], $row['storage_id'])) {
continue; continue;
} }
if ($fileDependent && (int)$row['file_parent'] === -1) {
// if it is a mount point we need to get the path from the mount manager
$mountManager = \OC\Files\Filesystem::getMountManager();
$mountPoint = $mountManager->findByStorageId($row['storage_id']);
if (!empty($mountPoint)) {
$path = $mountPoint[0]->getMountPoint();
$path = trim($path, '/');
$path = substr($path, strlen($owner) + 1); //normalize path to 'files/foo.txt`
$row['path'] = $path;
} else {
\OC::$server->getLogger()->warning(
'Could not resolve mount point for ' . $row['storage_id'],
['app' => 'OCP\Share']
);
}
}
$shares[] = $row; $shares[] = $row;
} }
@ -2290,7 +2306,7 @@ class Share extends Constants {
if ($fileDependent) { if ($fileDependent) {
$select = '`*PREFIX*share`.`id`, `*PREFIX*share`.`parent`, `share_type`, `path`, `storage`, ' $select = '`*PREFIX*share`.`id`, `*PREFIX*share`.`parent`, `share_type`, `path`, `storage`, '
. '`share_with`, `uid_owner` , `file_source`, `stime`, `*PREFIX*share`.`permissions`, ' . '`share_with`, `uid_owner` , `file_source`, `stime`, `*PREFIX*share`.`permissions`, '
. '`*PREFIX*storages`.`id` AS `storage_id`'; . '`*PREFIX*storages`.`id` AS `storage_id`, `*PREFIX*filecache`.`parent` as `file_parent`';
} else { } else {
$select = '`id`, `parent`, `share_type`, `share_with`, `uid_owner`, `item_source`, `stime`, `*PREFIX*share`.`permissions`'; $select = '`id`, `parent`, `share_type`, `share_with`, `uid_owner`, `item_source`, `stime`, `*PREFIX*share`.`permissions`';
} }
@ -2300,7 +2316,7 @@ class Share extends Constants {
$select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `*PREFIX*share`.`parent`,' $select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `*PREFIX*share`.`parent`,'
. ' `share_type`, `share_with`, `file_source`, `file_target`, `path`, `*PREFIX*share`.`permissions`, `stime`,' . ' `share_type`, `share_with`, `file_source`, `file_target`, `path`, `*PREFIX*share`.`permissions`, `stime`,'
. ' `expiration`, `token`, `storage`, `mail_send`, `uid_owner`, ' . ' `expiration`, `token`, `storage`, `mail_send`, `uid_owner`, '
. '`*PREFIX*storages`.`id` AS `storage_id`'; . '`*PREFIX*storages`.`id` AS `storage_id`, `*PREFIX*filecache`.`parent` as `file_parent`';
} else { } else {
$select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `share_with`, `*PREFIX*share`.`permissions`,' $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `share_with`, `*PREFIX*share`.`permissions`,'
. ' `stime`, `file_source`, `expiration`, `token`, `mail_send`, `uid_owner`'; . ' `stime`, `file_source`, `expiration`, `token`, `mail_send`, `uid_owner`';
@ -2317,7 +2333,7 @@ class Share extends Constants {
. '`*PREFIX*share`.`parent`, `share_type`, `share_with`, `uid_owner`,' . '`*PREFIX*share`.`parent`, `share_type`, `share_with`, `uid_owner`,'
. '`file_source`, `path`, `file_target`, `*PREFIX*share`.`permissions`,' . '`file_source`, `path`, `file_target`, `*PREFIX*share`.`permissions`,'
. '`stime`, `expiration`, `token`, `storage`, `mail_send`,' . '`stime`, `expiration`, `token`, `storage`, `mail_send`,'
. '`*PREFIX*storages`.`id` AS `storage_id`'; . '`*PREFIX*storages`.`id` AS `storage_id`, `*PREFIX*filecache`.`parent` as `file_parent`';
} }
} }
} }