mirror of https://github.com/nextcloud/server
improve performance of calculating dav permissions
Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
c7035eec05
commit
e98e8f10c9
|
@ -32,7 +32,9 @@
|
|||
*/
|
||||
namespace OC\Files;
|
||||
|
||||
use OCA\Files_Sharing\ISharedStorage;
|
||||
use OCP\Files\Cache\ICacheEntry;
|
||||
use OCP\Files\IHomeStorage;
|
||||
use OCP\Files\Mount\IMountPoint;
|
||||
use OCP\IUser;
|
||||
|
||||
|
@ -313,27 +315,13 @@ class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
|
|||
* @return bool
|
||||
*/
|
||||
public function isShared() {
|
||||
$sid = $this->getStorage()->getId();
|
||||
if (!is_null($sid)) {
|
||||
$sid = explode(':', $sid);
|
||||
return ($sid[0] === 'shared');
|
||||
}
|
||||
|
||||
return false;
|
||||
$storage = $this->getStorage();
|
||||
return $storage->instanceOfStorage(ISharedStorage::class);
|
||||
}
|
||||
|
||||
public function isMounted() {
|
||||
$storage = $this->getStorage();
|
||||
if ($storage->instanceOfStorage('\OCP\Files\IHomeStorage')) {
|
||||
return false;
|
||||
}
|
||||
$sid = $storage->getId();
|
||||
if (!is_null($sid)) {
|
||||
$sid = explode(':', $sid);
|
||||
return ($sid[0] !== 'home' and $sid[0] !== 'shared');
|
||||
}
|
||||
|
||||
return false;
|
||||
return !($storage->instanceOfStorage(IHomeStorage::class) || $storage->instanceOfStorage(ISharedStorage::class));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -59,23 +59,24 @@ class DavUtil {
|
|||
* @since 25.0.0
|
||||
*/
|
||||
public static function getDavPermissions(FileInfo $info): string {
|
||||
$permissions = $info->getPermissions();
|
||||
$p = '';
|
||||
if ($info->isShared()) {
|
||||
$p .= 'S';
|
||||
}
|
||||
if ($info->isShareable()) {
|
||||
if ($permissions & Constants::PERMISSION_SHARE) {
|
||||
$p .= 'R';
|
||||
}
|
||||
if ($info->isMounted()) {
|
||||
$p .= 'M';
|
||||
}
|
||||
if ($info->isReadable()) {
|
||||
if ($permissions & Constants::PERMISSION_READ) {
|
||||
$p .= 'G';
|
||||
}
|
||||
if ($info->isDeletable()) {
|
||||
if ($permissions & Constants::PERMISSION_DELETE) {
|
||||
$p .= 'D';
|
||||
}
|
||||
if ($info->isUpdateable()) {
|
||||
if ($permissions & Constants::PERMISSION_UPDATE) {
|
||||
$p .= 'NV'; // Renameable, Movable
|
||||
}
|
||||
|
||||
|
@ -86,7 +87,7 @@ class DavUtil {
|
|||
$rootEntry = $storage->getCache()->get('');
|
||||
$isWritable = $rootEntry->getPermissions() & Constants::PERMISSION_UPDATE;
|
||||
} else {
|
||||
$isWritable = $info->isUpdateable();
|
||||
$isWritable = $permissions & Constants::PERMISSION_UPDATE;
|
||||
}
|
||||
|
||||
if ($info->getType() === FileInfo::TYPE_FILE) {
|
||||
|
@ -94,7 +95,7 @@ class DavUtil {
|
|||
$p .= 'W';
|
||||
}
|
||||
} else {
|
||||
if ($info->isCreatable()) {
|
||||
if ($permissions & Constants::PERMISSION_CREATE) {
|
||||
$p .= 'CK';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue