we can take the permission directly from the share, no need to call the share api first

This commit is contained in:
Bjoern Schiessle 2014-05-07 16:49:07 +02:00
parent 254fa5eb22
commit 31bf2d4b33
1 changed files with 6 additions and 20 deletions

View File

@ -102,14 +102,15 @@ class Shared extends \OC\Files\Storage\Common {
/** /**
* @brief Get the permissions granted for a shared file * @brief Get the permissions granted for a shared file
* @param string Shared target file path * @param string Shared target file path
* @return int CRUDS permissions granted or false if not found * @return int CRUDS permissions granted
*/ */
public function getPermissions($target) { public function getPermissions($target) {
$source = $this->getFile($target); $permissions = $this->share['permissions'];
if ($source) { // part file are always have delete permissions
return $source['permissions']; if (pathinfo($target, PATHINFO_EXTENSION) === 'part') {
$permissions |= \OCP\PERMISSION_DELETE;
} }
return false; return $permissions;
} }
public function mkdir($path) { public function mkdir($path) {
@ -183,9 +184,6 @@ class Shared extends \OC\Files\Storage\Common {
} }
public function isCreatable($path) { public function isCreatable($path) {
if ($path == '') {
$path = $this->getMountPoint();
}
return ($this->getPermissions($path) & \OCP\PERMISSION_CREATE); return ($this->getPermissions($path) & \OCP\PERMISSION_CREATE);
} }
@ -194,23 +192,14 @@ class Shared extends \OC\Files\Storage\Common {
} }
public function isUpdatable($path) { public function isUpdatable($path) {
if ($path == '') {
$path = $this->getMountPoint();
}
return ($this->getPermissions($path) & \OCP\PERMISSION_UPDATE); return ($this->getPermissions($path) & \OCP\PERMISSION_UPDATE);
} }
public function isDeletable($path) { public function isDeletable($path) {
if ($path == '') {
$path = $this->getMountPoint();
}
return ($this->getPermissions($path) & \OCP\PERMISSION_DELETE); return ($this->getPermissions($path) & \OCP\PERMISSION_DELETE);
} }
public function isSharable($path) { public function isSharable($path) {
if ($path == '') {
$path = $this->getMountPoint();
}
return ($this->getPermissions($path) & \OCP\PERMISSION_SHARE); return ($this->getPermissions($path) & \OCP\PERMISSION_SHARE);
} }
@ -454,9 +443,6 @@ class Shared extends \OC\Files\Storage\Common {
} }
public function free_space($path) { public function free_space($path) {
if ($path == '') {
$path = $this->getMountPoint();
}
$source = $this->getSourcePath($path); $source = $this->getSourcePath($path);
if ($source) { if ($source) {
list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source); list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);