Compute share permissions in the view

The share permissions are now computed in the View/FileInfo instead of
storing them directly/permanently on the storage
This commit is contained in:
Vincent Petry 2015-12-08 11:32:18 +01:00
parent bec34f1275
commit e241d26316
3 changed files with 13 additions and 8 deletions

View File

@ -92,6 +92,7 @@ class ApiControllerTest extends TestCase {
[
'mtime' => 55,
'mimetype' => 'application/pdf',
'permissions' => 31,
'size' => 1234,
'etag' => 'MyEtag',
],
@ -111,7 +112,7 @@ class ApiControllerTest extends TestCase {
'parentId' => null,
'mtime' => 55000,
'name' => 'root.txt',
'permissions' => null,
'permissions' => 31,
'mimetype' => 'application/pdf',
'size' => 1234,
'type' => 'file',
@ -139,6 +140,7 @@ class ApiControllerTest extends TestCase {
[
'mtime' => 55,
'mimetype' => 'application/pdf',
'permissions' => 31,
'size' => 1234,
'etag' => 'MyEtag',
],
@ -155,6 +157,7 @@ class ApiControllerTest extends TestCase {
[
'mtime' => 999,
'mimetype' => 'application/binary',
'permissions' => 31,
'size' => 9876,
'etag' => 'SubEtag',
],
@ -174,7 +177,7 @@ class ApiControllerTest extends TestCase {
'parentId' => null,
'mtime' => 55000,
'name' => 'root.txt',
'permissions' => null,
'permissions' => 31,
'mimetype' => 'application/pdf',
'size' => 1234,
'type' => 'file',
@ -191,7 +194,7 @@ class ApiControllerTest extends TestCase {
'parentId' => null,
'mtime' => 999000,
'name' => 'root.txt',
'permissions' => null,
'permissions' => 31,
'mimetype' => 'application/binary',
'size' => 9876,
'type' => 'file',

View File

@ -100,6 +100,8 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
return $this->getType();
} else if ($offset === 'etag') {
return $this->getEtag();
} elseif ($offset === 'permissions') {
return $this->getPermissions();
} elseif (isset($this->data[$offset])) {
return $this->data[$offset];
} else {
@ -193,7 +195,11 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
* @return int
*/
public function getPermissions() {
return $this->data['permissions'];
$perms = $this->data['permissions'];
if (\OCP\Util::isSharingDisabledForUser()) {
$perms = $perms & ~\OCP\Constants::PERMISSION_SHARE;
}
return $perms;
}
/**

View File

@ -141,10 +141,6 @@ abstract class Common implements Storage {
}
public function isSharable($path) {
if (\OCP\Util::isSharingDisabledForUser()) {
return false;
}
return $this->isReadable($path);
}