diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-08-29 10:37:08 +0200 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-08-29 13:55:08 +0200 |
commit | b3cd9b557358a3aa506d7ad24883650d4449bb8c (patch) | |
tree | 8755c47a3fd92ea7a7444675dad8b591622d0cdf /lib/public | |
parent | e34f2c4799b271ac1b1c412af4bf2fa1f6279359 (diff) | |
download | nextcloud-server-b3cd9b557358a3aa506d7ad24883650d4449bb8c.tar.gz nextcloud-server-b3cd9b557358a3aa506d7ad24883650d4449bb8c.zip |
Move Dav fileid and permissions logic into OCP\Util to be able to use it for BulkUpload
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'lib/public')
-rw-r--r-- | lib/public/Util.php | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/lib/public/Util.php b/lib/public/Util.php index 6cd3eaa7f85..ad8818df3ca 100644 --- a/lib/public/Util.php +++ b/lib/public/Util.php @@ -628,4 +628,45 @@ class Util { } return true; } + + /** + * @param int $id Id of the file returned by FileInfo::getId + */ + public static function getDavFileId(int $id): string { + $instanceId = \OC_Util::getInstanceId(); + $id = sprintf('%08d', $id); + return $id . $instanceId; + } + + public static function getDavPermissions(\OCP\Files\FileInfo $info): string { + $p = ''; + if ($info->isShared()) { + $p .= 'S'; + } + if ($info->isShareable()) { + $p .= 'R'; + } + if ($info->isMounted()) { + $p .= 'M'; + } + if ($info->isReadable()) { + $p .= 'G'; + } + if ($info->isDeletable()) { + $p .= 'D'; + } + if ($info->isUpdateable()) { + $p .= 'NV'; // Renameable, Moveable + } + if ($info->getType() === \OCP\Files\FileInfo::TYPE_FILE) { + if ($info->isUpdateable()) { + $p .= 'W'; + } + } else { + if ($info->isCreatable()) { + $p .= 'CK'; + } + } + return $p; + } } |