John Molakvoæ
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
12 additions and
23 deletions
-
lib/private/Files/FileInfo.php
-
lib/public/Files/DavUtil.php
|
|
|
@ -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'; |
|
|
|
} |
|
|
|
} |
|
|
|
|