Merge pull request #8497 from owncloud/sharing_cleanup

[sharing] some small clean ups and bug fixes
This commit is contained in:
Björn Schießle 2014-05-07 14:18:41 -04:00
commit a2848ee11c
3 changed files with 9 additions and 24 deletions

View File

@ -125,7 +125,7 @@ class Helper {
$ids = array(); $ids = array();
while ($path !== '' && $path !== '.' && $path !== '/') { while ($path !== dirname($path)) {
$info = $ownerView->getFileInfo($path); $info = $ownerView->getFileInfo($path);
if ($info instanceof \OC\Files\FileInfo) { if ($info instanceof \OC\Files\FileInfo) {
$ids[] = $info['fileid']; $ids[] = $info['fileid'];

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);

View File

@ -38,14 +38,13 @@ class Shared_Updater {
\OC\Files\Filesystem::initMountPoints($user); \OC\Files\Filesystem::initMountPoints($user);
$view = new \OC\Files\View('/' . $user); $view = new \OC\Files\View('/' . $user);
if ($view->file_exists($path)) { if ($view->file_exists($path)) {
while ($path !== '/') { while ($path !== dirname($path)) {
$etag = $view->getETag($path); $etag = $view->getETag($path);
$view->putFileInfo($path, array('etag' => $etag)); $view->putFileInfo($path, array('etag' => $etag));
$path = dirname($path); $path = dirname($path);
} }
} else { } else {
error_log("error!" . 'can not update etags on ' . $path . ' for user ' . $user); \OCP\Util::writeLog('files_sharing', 'can not update etags on ' . $path . ' for user ' . $user . '. Path does not exists', \OCP\Util::DEBUG);
\OCP\Util::writeLog('files_sharing', 'can not update etags on ' . $path . ' for user ' . $user, \OCP\Util::ERROR);
} }
} }