@@ -30,14 +30,14 @@ |
||
| 30 | 30 | * Class Version14000Date20180712153140 |
| 31 | 31 | */ |
| 32 | 32 | class Version14000Date20180712153140 extends SimpleMigrationStep { |
| 33 | - public function changeSchema(\OCP\Migration\IOutput $output, \Closure $schemaClosure, array $options) { |
|
| 33 | + public function changeSchema(\OCP\Migration\IOutput $output, \Closure $schemaClosure, array $options) { |
|
| 34 | 34 | |
| 35 | - /** @var ISchemaWrapper $schema */ |
|
| 36 | - $schema = $schemaClosure(); |
|
| 35 | + /** @var ISchemaWrapper $schema */ |
|
| 36 | + $schema = $schemaClosure(); |
|
| 37 | 37 | |
| 38 | - $table = $schema->getTable('share'); |
|
| 39 | - $table->addColumn('note', 'text', ['notnull' => false]); |
|
| 38 | + $table = $schema->getTable('share'); |
|
| 39 | + $table->addColumn('note', 'text', ['notnull' => false]); |
|
| 40 | 40 | |
| 41 | - return $schema; |
|
| 42 | - } |
|
| 41 | + return $schema; |
|
| 42 | + } |
|
| 43 | 43 | } |
@@ -31,92 +31,92 @@ |
||
| 31 | 31 | |
| 32 | 32 | class NavigationController extends OCSController { |
| 33 | 33 | |
| 34 | - /** @var INavigationManager */ |
|
| 35 | - private $navigationManager; |
|
| 34 | + /** @var INavigationManager */ |
|
| 35 | + private $navigationManager; |
|
| 36 | 36 | |
| 37 | - /** @var IURLGenerator */ |
|
| 38 | - private $urlGenerator; |
|
| 37 | + /** @var IURLGenerator */ |
|
| 38 | + private $urlGenerator; |
|
| 39 | 39 | |
| 40 | - public function __construct(string $appName, IRequest $request, INavigationManager $navigationManager, IURLGenerator $urlGenerator) { |
|
| 41 | - parent::__construct($appName, $request); |
|
| 42 | - $this->navigationManager = $navigationManager; |
|
| 43 | - $this->urlGenerator = $urlGenerator; |
|
| 44 | - } |
|
| 40 | + public function __construct(string $appName, IRequest $request, INavigationManager $navigationManager, IURLGenerator $urlGenerator) { |
|
| 41 | + parent::__construct($appName, $request); |
|
| 42 | + $this->navigationManager = $navigationManager; |
|
| 43 | + $this->urlGenerator = $urlGenerator; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @NoAdminRequired |
|
| 48 | - * @NoCSRFRequired |
|
| 49 | - * |
|
| 50 | - * @param bool $absolute |
|
| 51 | - * @return DataResponse |
|
| 52 | - */ |
|
| 53 | - public function getAppsNavigation(bool $absolute = false): DataResponse { |
|
| 54 | - $navigation = $this->navigationManager->getAll(); |
|
| 55 | - if ($absolute) { |
|
| 56 | - $navigation = $this->rewriteToAbsoluteUrls($navigation); |
|
| 57 | - } |
|
| 58 | - $navigation = array_values($navigation); |
|
| 59 | - $etag = $this->generateETag($navigation); |
|
| 60 | - if ($this->request->getHeader('If-None-Match') === $etag) { |
|
| 61 | - return new DataResponse([], Http::STATUS_NOT_MODIFIED); |
|
| 62 | - } |
|
| 63 | - $response = new DataResponse($navigation); |
|
| 64 | - $response->setETag($etag); |
|
| 65 | - return $response; |
|
| 66 | - } |
|
| 46 | + /** |
|
| 47 | + * @NoAdminRequired |
|
| 48 | + * @NoCSRFRequired |
|
| 49 | + * |
|
| 50 | + * @param bool $absolute |
|
| 51 | + * @return DataResponse |
|
| 52 | + */ |
|
| 53 | + public function getAppsNavigation(bool $absolute = false): DataResponse { |
|
| 54 | + $navigation = $this->navigationManager->getAll(); |
|
| 55 | + if ($absolute) { |
|
| 56 | + $navigation = $this->rewriteToAbsoluteUrls($navigation); |
|
| 57 | + } |
|
| 58 | + $navigation = array_values($navigation); |
|
| 59 | + $etag = $this->generateETag($navigation); |
|
| 60 | + if ($this->request->getHeader('If-None-Match') === $etag) { |
|
| 61 | + return new DataResponse([], Http::STATUS_NOT_MODIFIED); |
|
| 62 | + } |
|
| 63 | + $response = new DataResponse($navigation); |
|
| 64 | + $response->setETag($etag); |
|
| 65 | + return $response; |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * @NoAdminRequired |
|
| 70 | - * @NoCSRFRequired |
|
| 71 | - * |
|
| 72 | - * @param bool $absolute |
|
| 73 | - * @return DataResponse |
|
| 74 | - */ |
|
| 75 | - public function getSettingsNavigation(bool $absolute = false): DataResponse { |
|
| 76 | - $navigation = $this->navigationManager->getAll('settings'); |
|
| 77 | - if ($absolute) { |
|
| 78 | - $navigation = $this->rewriteToAbsoluteUrls($navigation); |
|
| 79 | - } |
|
| 80 | - $navigation = array_values($navigation); |
|
| 81 | - $etag = $this->generateETag($navigation); |
|
| 82 | - if ($this->request->getHeader('If-None-Match') === $etag) { |
|
| 83 | - return new DataResponse([], Http::STATUS_NOT_MODIFIED); |
|
| 84 | - } |
|
| 85 | - $response = new DataResponse($navigation); |
|
| 86 | - $response->setETag($etag); |
|
| 87 | - return $response; |
|
| 88 | - } |
|
| 68 | + /** |
|
| 69 | + * @NoAdminRequired |
|
| 70 | + * @NoCSRFRequired |
|
| 71 | + * |
|
| 72 | + * @param bool $absolute |
|
| 73 | + * @return DataResponse |
|
| 74 | + */ |
|
| 75 | + public function getSettingsNavigation(bool $absolute = false): DataResponse { |
|
| 76 | + $navigation = $this->navigationManager->getAll('settings'); |
|
| 77 | + if ($absolute) { |
|
| 78 | + $navigation = $this->rewriteToAbsoluteUrls($navigation); |
|
| 79 | + } |
|
| 80 | + $navigation = array_values($navigation); |
|
| 81 | + $etag = $this->generateETag($navigation); |
|
| 82 | + if ($this->request->getHeader('If-None-Match') === $etag) { |
|
| 83 | + return new DataResponse([], Http::STATUS_NOT_MODIFIED); |
|
| 84 | + } |
|
| 85 | + $response = new DataResponse($navigation); |
|
| 86 | + $response->setETag($etag); |
|
| 87 | + return $response; |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * Generate an ETag for a list of navigation entries |
|
| 92 | - * |
|
| 93 | - * @param array $navigation |
|
| 94 | - * @return string |
|
| 95 | - */ |
|
| 96 | - private function generateETag(array $navigation): string { |
|
| 97 | - foreach ($navigation as &$nav) { |
|
| 98 | - if ($nav['id'] === 'logout') { |
|
| 99 | - $nav['href'] = 'logout'; |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - return md5(json_encode($navigation)); |
|
| 103 | - } |
|
| 90 | + /** |
|
| 91 | + * Generate an ETag for a list of navigation entries |
|
| 92 | + * |
|
| 93 | + * @param array $navigation |
|
| 94 | + * @return string |
|
| 95 | + */ |
|
| 96 | + private function generateETag(array $navigation): string { |
|
| 97 | + foreach ($navigation as &$nav) { |
|
| 98 | + if ($nav['id'] === 'logout') { |
|
| 99 | + $nav['href'] = 'logout'; |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + return md5(json_encode($navigation)); |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * Rewrite href attribute of navigation entries to an absolute URL |
|
| 107 | - * |
|
| 108 | - * @param array $navigation |
|
| 109 | - * @return array |
|
| 110 | - */ |
|
| 111 | - private function rewriteToAbsoluteUrls(array $navigation): array { |
|
| 112 | - foreach ($navigation as &$entry) { |
|
| 113 | - if (0 !== strpos($entry['href'], $this->urlGenerator->getBaseUrl())) { |
|
| 114 | - $entry['href'] = $this->urlGenerator->getAbsoluteURL($entry['href']); |
|
| 115 | - } |
|
| 116 | - if (0 !== strpos($entry['icon'], $this->urlGenerator->getBaseUrl())) { |
|
| 117 | - $entry['icon'] = $this->urlGenerator->getAbsoluteURL($entry['icon']); |
|
| 118 | - } |
|
| 119 | - } |
|
| 120 | - return $navigation; |
|
| 121 | - } |
|
| 105 | + /** |
|
| 106 | + * Rewrite href attribute of navigation entries to an absolute URL |
|
| 107 | + * |
|
| 108 | + * @param array $navigation |
|
| 109 | + * @return array |
|
| 110 | + */ |
|
| 111 | + private function rewriteToAbsoluteUrls(array $navigation): array { |
|
| 112 | + foreach ($navigation as &$entry) { |
|
| 113 | + if (0 !== strpos($entry['href'], $this->urlGenerator->getBaseUrl())) { |
|
| 114 | + $entry['href'] = $this->urlGenerator->getAbsoluteURL($entry['href']); |
|
| 115 | + } |
|
| 116 | + if (0 !== strpos($entry['icon'], $this->urlGenerator->getBaseUrl())) { |
|
| 117 | + $entry['icon'] = $this->urlGenerator->getAbsoluteURL($entry['icon']); |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | + return $navigation; |
|
| 121 | + } |
|
| 122 | 122 | } |
@@ -37,67 +37,67 @@ |
||
| 37 | 37 | */ |
| 38 | 38 | interface IAvatar { |
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * get the users avatar |
|
| 42 | - * @param int $size size in px of the avatar, avatars are square, defaults to 64, -1 can be used to not scale the image |
|
| 43 | - * @return boolean|\OCP\IImage containing the avatar or false if there's no image |
|
| 44 | - * @since 6.0.0 - size of -1 was added in 9.0.0 |
|
| 45 | - */ |
|
| 46 | - public function get($size = 64); |
|
| 40 | + /** |
|
| 41 | + * get the users avatar |
|
| 42 | + * @param int $size size in px of the avatar, avatars are square, defaults to 64, -1 can be used to not scale the image |
|
| 43 | + * @return boolean|\OCP\IImage containing the avatar or false if there's no image |
|
| 44 | + * @since 6.0.0 - size of -1 was added in 9.0.0 |
|
| 45 | + */ |
|
| 46 | + public function get($size = 64); |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * Check if an avatar exists for the user |
|
| 50 | - * |
|
| 51 | - * @return bool |
|
| 52 | - * @since 8.1.0 |
|
| 53 | - */ |
|
| 54 | - public function exists(); |
|
| 48 | + /** |
|
| 49 | + * Check if an avatar exists for the user |
|
| 50 | + * |
|
| 51 | + * @return bool |
|
| 52 | + * @since 8.1.0 |
|
| 53 | + */ |
|
| 54 | + public function exists(); |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Check if the avatar of a user is a custom uploaded one |
|
| 58 | - * |
|
| 59 | - * @return bool |
|
| 60 | - * @since 14.0.0 |
|
| 61 | - */ |
|
| 62 | - public function isCustomAvatar(): bool; |
|
| 56 | + /** |
|
| 57 | + * Check if the avatar of a user is a custom uploaded one |
|
| 58 | + * |
|
| 59 | + * @return bool |
|
| 60 | + * @since 14.0.0 |
|
| 61 | + */ |
|
| 62 | + public function isCustomAvatar(): bool; |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * sets the users avatar |
|
| 66 | - * @param \OCP\IImage|resource|string $data An image object, imagedata or path to set a new avatar |
|
| 67 | - * @throws \Exception if the provided file is not a jpg or png image |
|
| 68 | - * @throws \Exception if the provided image is not valid |
|
| 69 | - * @throws \OC\NotSquareException if the image is not square |
|
| 70 | - * @return void |
|
| 71 | - * @since 6.0.0 |
|
| 72 | - */ |
|
| 73 | - public function set($data); |
|
| 64 | + /** |
|
| 65 | + * sets the users avatar |
|
| 66 | + * @param \OCP\IImage|resource|string $data An image object, imagedata or path to set a new avatar |
|
| 67 | + * @throws \Exception if the provided file is not a jpg or png image |
|
| 68 | + * @throws \Exception if the provided image is not valid |
|
| 69 | + * @throws \OC\NotSquareException if the image is not square |
|
| 70 | + * @return void |
|
| 71 | + * @since 6.0.0 |
|
| 72 | + */ |
|
| 73 | + public function set($data); |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * remove the users avatar |
|
| 77 | - * @return void |
|
| 78 | - * @since 6.0.0 |
|
| 79 | - */ |
|
| 80 | - public function remove(); |
|
| 75 | + /** |
|
| 76 | + * remove the users avatar |
|
| 77 | + * @return void |
|
| 78 | + * @since 6.0.0 |
|
| 79 | + */ |
|
| 80 | + public function remove(); |
|
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * Get the file of the avatar |
|
| 84 | - * @param int $size -1 can be used to not scale the image |
|
| 85 | - * @return File |
|
| 86 | - * @throws NotFoundException |
|
| 87 | - * @since 9.0.0 |
|
| 88 | - */ |
|
| 89 | - public function getFile($size); |
|
| 82 | + /** |
|
| 83 | + * Get the file of the avatar |
|
| 84 | + * @param int $size -1 can be used to not scale the image |
|
| 85 | + * @return File |
|
| 86 | + * @throws NotFoundException |
|
| 87 | + * @since 9.0.0 |
|
| 88 | + */ |
|
| 89 | + public function getFile($size); |
|
| 90 | 90 | |
| 91 | - /** |
|
| 92 | - * @param string $text |
|
| 93 | - * @return Color Object containting r g b int in the range [0, 255] |
|
| 94 | - * @since 14.0.0 |
|
| 95 | - */ |
|
| 96 | - public function avatarBackgroundColor(string $text); |
|
| 91 | + /** |
|
| 92 | + * @param string $text |
|
| 93 | + * @return Color Object containting r g b int in the range [0, 255] |
|
| 94 | + * @since 14.0.0 |
|
| 95 | + */ |
|
| 96 | + public function avatarBackgroundColor(string $text); |
|
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * Handle a changed user |
|
| 100 | - * @since 13.0.0 |
|
| 101 | - */ |
|
| 102 | - public function userChanged($feature, $oldValue, $newValue); |
|
| 98 | + /** |
|
| 99 | + * Handle a changed user |
|
| 100 | + * @since 13.0.0 |
|
| 101 | + */ |
|
| 102 | + public function userChanged($feature, $oldValue, $newValue); |
|
| 103 | 103 | } |
@@ -25,26 +25,26 @@ |
||
| 25 | 25 | |
| 26 | 26 | class EnterpriseBundle extends Bundle { |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * {@inheritDoc} |
|
| 30 | - */ |
|
| 31 | - public function getName(): string { |
|
| 32 | - return $this->l10n->t('Enterprise bundle'); |
|
| 33 | - } |
|
| 28 | + /** |
|
| 29 | + * {@inheritDoc} |
|
| 30 | + */ |
|
| 31 | + public function getName(): string { |
|
| 32 | + return $this->l10n->t('Enterprise bundle'); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * {@inheritDoc} |
|
| 37 | - */ |
|
| 38 | - public function getAppIdentifiers(): array { |
|
| 39 | - return [ |
|
| 40 | - 'admin_audit', |
|
| 41 | - 'user_ldap', |
|
| 42 | - 'files_retention', |
|
| 43 | - 'files_automatedtagging', |
|
| 44 | - 'user_saml', |
|
| 45 | - 'files_accesscontrol', |
|
| 46 | - 'terms_of_service', |
|
| 47 | - ]; |
|
| 48 | - } |
|
| 35 | + /** |
|
| 36 | + * {@inheritDoc} |
|
| 37 | + */ |
|
| 38 | + public function getAppIdentifiers(): array { |
|
| 39 | + return [ |
|
| 40 | + 'admin_audit', |
|
| 41 | + 'user_ldap', |
|
| 42 | + 'files_retention', |
|
| 43 | + 'files_automatedtagging', |
|
| 44 | + 'user_saml', |
|
| 45 | + 'files_accesscontrol', |
|
| 46 | + 'terms_of_service', |
|
| 47 | + ]; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | 50 | } |
@@ -31,21 +31,21 @@ |
||
| 31 | 31 | |
| 32 | 32 | class Version1002Date20180821043638 extends SimpleMigrationStep { |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @param IOutput $output |
|
| 36 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 37 | - * @param array $options |
|
| 38 | - * |
|
| 39 | - * @return ISchemaWrapper |
|
| 40 | - */ |
|
| 41 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
| 42 | - /** @var ISchemaWrapper $schema */ |
|
| 43 | - $schema = $schemaClosure(); |
|
| 44 | - $table = $schema->getTable('twofactor_backupcodes'); |
|
| 45 | - |
|
| 46 | - $table->getColumn('code')->setLength(128); |
|
| 47 | - |
|
| 48 | - return $schema; |
|
| 49 | - } |
|
| 34 | + /** |
|
| 35 | + * @param IOutput $output |
|
| 36 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
| 37 | + * @param array $options |
|
| 38 | + * |
|
| 39 | + * @return ISchemaWrapper |
|
| 40 | + */ |
|
| 41 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) { |
|
| 42 | + /** @var ISchemaWrapper $schema */ |
|
| 43 | + $schema = $schemaClosure(); |
|
| 44 | + $table = $schema->getTable('twofactor_backupcodes'); |
|
| 45 | + |
|
| 46 | + $table->getColumn('code')->setLength(128); |
|
| 47 | + |
|
| 48 | + return $schema; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | 51 | } |
@@ -32,166 +32,166 @@ |
||
| 32 | 32 | use OCP\Files\Mount\IMountPoint; |
| 33 | 33 | |
| 34 | 34 | class Manager implements IMountManager { |
| 35 | - /** @var MountPoint[] */ |
|
| 36 | - private $mounts = []; |
|
| 37 | - |
|
| 38 | - /** @var CappedMemoryCache */ |
|
| 39 | - private $pathCache; |
|
| 40 | - |
|
| 41 | - /** @var CappedMemoryCache */ |
|
| 42 | - private $inPathCache; |
|
| 43 | - |
|
| 44 | - public function __construct() { |
|
| 45 | - $this->pathCache = new CappedMemoryCache(); |
|
| 46 | - $this->inPathCache = new CappedMemoryCache(); |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * @param IMountPoint $mount |
|
| 51 | - */ |
|
| 52 | - public function addMount(IMountPoint $mount) { |
|
| 53 | - $this->mounts[$mount->getMountPoint()] = $mount; |
|
| 54 | - $this->pathCache->clear(); |
|
| 55 | - $this->inPathCache->clear(); |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * @param string $mountPoint |
|
| 60 | - */ |
|
| 61 | - public function removeMount(string $mountPoint) { |
|
| 62 | - $mountPoint = Filesystem::normalizePath($mountPoint); |
|
| 63 | - if (\strlen($mountPoint) > 1) { |
|
| 64 | - $mountPoint .= '/'; |
|
| 65 | - } |
|
| 66 | - unset($this->mounts[$mountPoint]); |
|
| 67 | - $this->pathCache->clear(); |
|
| 68 | - $this->inPathCache->clear(); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * @param string $mountPoint |
|
| 73 | - * @param string $target |
|
| 74 | - */ |
|
| 75 | - public function moveMount(string $mountPoint, string $target) { |
|
| 76 | - $this->mounts[$target] = $this->mounts[$mountPoint]; |
|
| 77 | - unset($this->mounts[$mountPoint]); |
|
| 78 | - $this->pathCache->clear(); |
|
| 79 | - $this->inPathCache->clear(); |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * Find the mount for $path |
|
| 84 | - * |
|
| 85 | - * @param string $path |
|
| 86 | - * @return MountPoint|null |
|
| 87 | - */ |
|
| 88 | - public function find(string $path) { |
|
| 89 | - \OC_Util::setupFS(); |
|
| 90 | - $path = Filesystem::normalizePath($path); |
|
| 91 | - |
|
| 92 | - if (isset($this->pathCache[$path])) { |
|
| 93 | - return $this->pathCache[$path]; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - $current = $path; |
|
| 97 | - while (true) { |
|
| 98 | - $mountPoint = $current . '/'; |
|
| 99 | - if (isset($this->mounts[$mountPoint])) { |
|
| 100 | - $this->pathCache[$path] = $this->mounts[$mountPoint]; |
|
| 101 | - return $this->mounts[$mountPoint]; |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - if ($current === '') { |
|
| 105 | - return null; |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - $current = dirname($current); |
|
| 109 | - if ($current === '.' || $current === '/') { |
|
| 110 | - $current = ''; |
|
| 111 | - } |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * Find all mounts in $path |
|
| 117 | - * |
|
| 118 | - * @param string $path |
|
| 119 | - * @return MountPoint[] |
|
| 120 | - */ |
|
| 121 | - public function findIn(string $path): array { |
|
| 122 | - \OC_Util::setupFS(); |
|
| 123 | - $path = $this->formatPath($path); |
|
| 124 | - |
|
| 125 | - if (isset($this->inPathCache[$path])) { |
|
| 126 | - return $this->inPathCache[$path]; |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - $result = []; |
|
| 130 | - $pathLength = \strlen($path); |
|
| 131 | - $mountPoints = array_keys($this->mounts); |
|
| 132 | - foreach ($mountPoints as $mountPoint) { |
|
| 133 | - if (substr($mountPoint, 0, $pathLength) === $path && \strlen($mountPoint) > $pathLength) { |
|
| 134 | - $result[] = $this->mounts[$mountPoint]; |
|
| 135 | - } |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - $this->inPathCache[$path] = $result; |
|
| 139 | - return $result; |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - public function clear() { |
|
| 143 | - $this->mounts = []; |
|
| 144 | - $this->pathCache->clear(); |
|
| 145 | - $this->inPathCache->clear(); |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * Find mounts by storage id |
|
| 150 | - * |
|
| 151 | - * @param string $id |
|
| 152 | - * @return MountPoint[] |
|
| 153 | - */ |
|
| 154 | - public function findByStorageId(string $id): array { |
|
| 155 | - \OC_Util::setupFS(); |
|
| 156 | - if (\strlen($id) > 64) { |
|
| 157 | - $id = md5($id); |
|
| 158 | - } |
|
| 159 | - $result = []; |
|
| 160 | - foreach ($this->mounts as $mount) { |
|
| 161 | - if ($mount->getStorageId() === $id) { |
|
| 162 | - $result[] = $mount; |
|
| 163 | - } |
|
| 164 | - } |
|
| 165 | - return $result; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - /** |
|
| 169 | - * @return MountPoint[] |
|
| 170 | - */ |
|
| 171 | - public function getAll(): array { |
|
| 172 | - return $this->mounts; |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * Find mounts by numeric storage id |
|
| 177 | - * |
|
| 178 | - * @param int $id |
|
| 179 | - * @return MountPoint[] |
|
| 180 | - */ |
|
| 181 | - public function findByNumericId(int $id): array { |
|
| 182 | - $storageId = \OC\Files\Cache\Storage::getStorageId($id); |
|
| 183 | - return $this->findByStorageId($storageId); |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * @param string $path |
|
| 188 | - * @return string |
|
| 189 | - */ |
|
| 190 | - private function formatPath(string $path): string { |
|
| 191 | - $path = Filesystem::normalizePath($path); |
|
| 192 | - if (\strlen($path) > 1) { |
|
| 193 | - $path .= '/'; |
|
| 194 | - } |
|
| 195 | - return $path; |
|
| 196 | - } |
|
| 35 | + /** @var MountPoint[] */ |
|
| 36 | + private $mounts = []; |
|
| 37 | + |
|
| 38 | + /** @var CappedMemoryCache */ |
|
| 39 | + private $pathCache; |
|
| 40 | + |
|
| 41 | + /** @var CappedMemoryCache */ |
|
| 42 | + private $inPathCache; |
|
| 43 | + |
|
| 44 | + public function __construct() { |
|
| 45 | + $this->pathCache = new CappedMemoryCache(); |
|
| 46 | + $this->inPathCache = new CappedMemoryCache(); |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * @param IMountPoint $mount |
|
| 51 | + */ |
|
| 52 | + public function addMount(IMountPoint $mount) { |
|
| 53 | + $this->mounts[$mount->getMountPoint()] = $mount; |
|
| 54 | + $this->pathCache->clear(); |
|
| 55 | + $this->inPathCache->clear(); |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * @param string $mountPoint |
|
| 60 | + */ |
|
| 61 | + public function removeMount(string $mountPoint) { |
|
| 62 | + $mountPoint = Filesystem::normalizePath($mountPoint); |
|
| 63 | + if (\strlen($mountPoint) > 1) { |
|
| 64 | + $mountPoint .= '/'; |
|
| 65 | + } |
|
| 66 | + unset($this->mounts[$mountPoint]); |
|
| 67 | + $this->pathCache->clear(); |
|
| 68 | + $this->inPathCache->clear(); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * @param string $mountPoint |
|
| 73 | + * @param string $target |
|
| 74 | + */ |
|
| 75 | + public function moveMount(string $mountPoint, string $target) { |
|
| 76 | + $this->mounts[$target] = $this->mounts[$mountPoint]; |
|
| 77 | + unset($this->mounts[$mountPoint]); |
|
| 78 | + $this->pathCache->clear(); |
|
| 79 | + $this->inPathCache->clear(); |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * Find the mount for $path |
|
| 84 | + * |
|
| 85 | + * @param string $path |
|
| 86 | + * @return MountPoint|null |
|
| 87 | + */ |
|
| 88 | + public function find(string $path) { |
|
| 89 | + \OC_Util::setupFS(); |
|
| 90 | + $path = Filesystem::normalizePath($path); |
|
| 91 | + |
|
| 92 | + if (isset($this->pathCache[$path])) { |
|
| 93 | + return $this->pathCache[$path]; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + $current = $path; |
|
| 97 | + while (true) { |
|
| 98 | + $mountPoint = $current . '/'; |
|
| 99 | + if (isset($this->mounts[$mountPoint])) { |
|
| 100 | + $this->pathCache[$path] = $this->mounts[$mountPoint]; |
|
| 101 | + return $this->mounts[$mountPoint]; |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + if ($current === '') { |
|
| 105 | + return null; |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + $current = dirname($current); |
|
| 109 | + if ($current === '.' || $current === '/') { |
|
| 110 | + $current = ''; |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * Find all mounts in $path |
|
| 117 | + * |
|
| 118 | + * @param string $path |
|
| 119 | + * @return MountPoint[] |
|
| 120 | + */ |
|
| 121 | + public function findIn(string $path): array { |
|
| 122 | + \OC_Util::setupFS(); |
|
| 123 | + $path = $this->formatPath($path); |
|
| 124 | + |
|
| 125 | + if (isset($this->inPathCache[$path])) { |
|
| 126 | + return $this->inPathCache[$path]; |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + $result = []; |
|
| 130 | + $pathLength = \strlen($path); |
|
| 131 | + $mountPoints = array_keys($this->mounts); |
|
| 132 | + foreach ($mountPoints as $mountPoint) { |
|
| 133 | + if (substr($mountPoint, 0, $pathLength) === $path && \strlen($mountPoint) > $pathLength) { |
|
| 134 | + $result[] = $this->mounts[$mountPoint]; |
|
| 135 | + } |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + $this->inPathCache[$path] = $result; |
|
| 139 | + return $result; |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + public function clear() { |
|
| 143 | + $this->mounts = []; |
|
| 144 | + $this->pathCache->clear(); |
|
| 145 | + $this->inPathCache->clear(); |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + /** |
|
| 149 | + * Find mounts by storage id |
|
| 150 | + * |
|
| 151 | + * @param string $id |
|
| 152 | + * @return MountPoint[] |
|
| 153 | + */ |
|
| 154 | + public function findByStorageId(string $id): array { |
|
| 155 | + \OC_Util::setupFS(); |
|
| 156 | + if (\strlen($id) > 64) { |
|
| 157 | + $id = md5($id); |
|
| 158 | + } |
|
| 159 | + $result = []; |
|
| 160 | + foreach ($this->mounts as $mount) { |
|
| 161 | + if ($mount->getStorageId() === $id) { |
|
| 162 | + $result[] = $mount; |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | + return $result; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + /** |
|
| 169 | + * @return MountPoint[] |
|
| 170 | + */ |
|
| 171 | + public function getAll(): array { |
|
| 172 | + return $this->mounts; |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * Find mounts by numeric storage id |
|
| 177 | + * |
|
| 178 | + * @param int $id |
|
| 179 | + * @return MountPoint[] |
|
| 180 | + */ |
|
| 181 | + public function findByNumericId(int $id): array { |
|
| 182 | + $storageId = \OC\Files\Cache\Storage::getStorageId($id); |
|
| 183 | + return $this->findByStorageId($storageId); |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * @param string $path |
|
| 188 | + * @return string |
|
| 189 | + */ |
|
| 190 | + private function formatPath(string $path): string { |
|
| 191 | + $path = Filesystem::normalizePath($path); |
|
| 192 | + if (\strlen($path) > 1) { |
|
| 193 | + $path .= '/'; |
|
| 194 | + } |
|
| 195 | + return $path; |
|
| 196 | + } |
|
| 197 | 197 | } |
@@ -29,15 +29,15 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | interface ICollectBreadcrumbs extends IReporter { |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Collect breadcrumbs for crash reports |
|
| 34 | - * |
|
| 35 | - * @param string $message |
|
| 36 | - * @param string $category |
|
| 37 | - * @param array $context |
|
| 38 | - * |
|
| 39 | - * @since 15.0.0 |
|
| 40 | - */ |
|
| 41 | - public function collect(string $message, string $category, array $context = []); |
|
| 32 | + /** |
|
| 33 | + * Collect breadcrumbs for crash reports |
|
| 34 | + * |
|
| 35 | + * @param string $message |
|
| 36 | + * @param string $category |
|
| 37 | + * @param array $context |
|
| 38 | + * |
|
| 39 | + * @since 15.0.0 |
|
| 40 | + */ |
|
| 41 | + public function collect(string $message, string $category, array $context = []); |
|
| 42 | 42 | |
| 43 | 43 | } |
@@ -32,76 +32,76 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | interface ICloudFederationProviderManager { |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Registers an callback function which must return an cloud federation provider |
|
| 37 | - * |
|
| 38 | - * @param string $resourceType which resource type does the provider handles |
|
| 39 | - * @param string $displayName user facing name of the federated share provider |
|
| 40 | - * @param callable $callback |
|
| 41 | - * @throws Exceptions\ProviderAlreadyExistsException |
|
| 42 | - * |
|
| 43 | - * @since 14.0.0 |
|
| 44 | - */ |
|
| 45 | - public function addCloudFederationProvider($resourceType, $displayName, callable $callback); |
|
| 35 | + /** |
|
| 36 | + * Registers an callback function which must return an cloud federation provider |
|
| 37 | + * |
|
| 38 | + * @param string $resourceType which resource type does the provider handles |
|
| 39 | + * @param string $displayName user facing name of the federated share provider |
|
| 40 | + * @param callable $callback |
|
| 41 | + * @throws Exceptions\ProviderAlreadyExistsException |
|
| 42 | + * |
|
| 43 | + * @since 14.0.0 |
|
| 44 | + */ |
|
| 45 | + public function addCloudFederationProvider($resourceType, $displayName, callable $callback); |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * remove cloud federation provider |
|
| 49 | - * |
|
| 50 | - * @param string $resourceType |
|
| 51 | - * |
|
| 52 | - * @since 14.0.0 |
|
| 53 | - */ |
|
| 54 | - public function removeCloudFederationProvider($resourceType); |
|
| 47 | + /** |
|
| 48 | + * remove cloud federation provider |
|
| 49 | + * |
|
| 50 | + * @param string $resourceType |
|
| 51 | + * |
|
| 52 | + * @since 14.0.0 |
|
| 53 | + */ |
|
| 54 | + public function removeCloudFederationProvider($resourceType); |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * get a list of all cloudFederationProviders |
|
| 58 | - * |
|
| 59 | - * @return array [resourceType => ['resourceType' => $resourceType, 'displayName' => $displayName, 'callback' => callback]] |
|
| 60 | - * |
|
| 61 | - * @since 14.0.0 |
|
| 62 | - */ |
|
| 63 | - public function getAllCloudFederationProviders(); |
|
| 56 | + /** |
|
| 57 | + * get a list of all cloudFederationProviders |
|
| 58 | + * |
|
| 59 | + * @return array [resourceType => ['resourceType' => $resourceType, 'displayName' => $displayName, 'callback' => callback]] |
|
| 60 | + * |
|
| 61 | + * @since 14.0.0 |
|
| 62 | + */ |
|
| 63 | + public function getAllCloudFederationProviders(); |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * get a specific cloud federation provider |
|
| 67 | - * |
|
| 68 | - * @param string $resourceType |
|
| 69 | - * @return ICloudFederationProvider |
|
| 70 | - * @throws Exceptions\ProviderDoesNotExistsException |
|
| 71 | - * |
|
| 72 | - * @since 14.0.0 |
|
| 73 | - */ |
|
| 74 | - public function getCloudFederationProvider($resourceType); |
|
| 65 | + /** |
|
| 66 | + * get a specific cloud federation provider |
|
| 67 | + * |
|
| 68 | + * @param string $resourceType |
|
| 69 | + * @return ICloudFederationProvider |
|
| 70 | + * @throws Exceptions\ProviderDoesNotExistsException |
|
| 71 | + * |
|
| 72 | + * @since 14.0.0 |
|
| 73 | + */ |
|
| 74 | + public function getCloudFederationProvider($resourceType); |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * send federated share |
|
| 78 | - * |
|
| 79 | - * @param ICloudFederationShare $share |
|
| 80 | - * @return mixed |
|
| 81 | - * |
|
| 82 | - * @since 14.0.0 |
|
| 83 | - */ |
|
| 84 | - public function sendShare(ICloudFederationShare $share); |
|
| 76 | + /** |
|
| 77 | + * send federated share |
|
| 78 | + * |
|
| 79 | + * @param ICloudFederationShare $share |
|
| 80 | + * @return mixed |
|
| 81 | + * |
|
| 82 | + * @since 14.0.0 |
|
| 83 | + */ |
|
| 84 | + public function sendShare(ICloudFederationShare $share); |
|
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * send notification about existing share |
|
| 88 | - * |
|
| 89 | - * @param string $url |
|
| 90 | - * @param ICloudFederationNotification $notification |
|
| 91 | - * @return mixed |
|
| 92 | - * |
|
| 93 | - * @since 14.0.0 |
|
| 94 | - */ |
|
| 95 | - public function sendNotification($url, ICloudFederationNotification $notification); |
|
| 86 | + /** |
|
| 87 | + * send notification about existing share |
|
| 88 | + * |
|
| 89 | + * @param string $url |
|
| 90 | + * @param ICloudFederationNotification $notification |
|
| 91 | + * @return mixed |
|
| 92 | + * |
|
| 93 | + * @since 14.0.0 |
|
| 94 | + */ |
|
| 95 | + public function sendNotification($url, ICloudFederationNotification $notification); |
|
| 96 | 96 | |
| 97 | - /** |
|
| 98 | - * check if the new cloud federation API is ready to be used |
|
| 99 | - * |
|
| 100 | - * @return bool |
|
| 101 | - * |
|
| 102 | - * @since 14.0.0 |
|
| 103 | - */ |
|
| 104 | - public function isReady(); |
|
| 97 | + /** |
|
| 98 | + * check if the new cloud federation API is ready to be used |
|
| 99 | + * |
|
| 100 | + * @return bool |
|
| 101 | + * |
|
| 102 | + * @since 14.0.0 |
|
| 103 | + */ |
|
| 104 | + public function isReady(); |
|
| 105 | 105 | |
| 106 | 106 | |
| 107 | 107 | } |
@@ -34,22 +34,22 @@ |
||
| 34 | 34 | */ |
| 35 | 35 | interface IProvidesIcons extends IProvider { |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Get the path to the light (white) icon of this provider |
|
| 39 | - * |
|
| 40 | - * @return String |
|
| 41 | - * |
|
| 42 | - * @since 15.0.0 |
|
| 43 | - */ |
|
| 44 | - public function getLightIcon(): String; |
|
| 37 | + /** |
|
| 38 | + * Get the path to the light (white) icon of this provider |
|
| 39 | + * |
|
| 40 | + * @return String |
|
| 41 | + * |
|
| 42 | + * @since 15.0.0 |
|
| 43 | + */ |
|
| 44 | + public function getLightIcon(): String; |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Get the path to the dark (black) icon of this provider |
|
| 48 | - * |
|
| 49 | - * @return String |
|
| 50 | - * |
|
| 51 | - * @since 15.0.0 |
|
| 52 | - */ |
|
| 53 | - public function getDarkIcon(): String; |
|
| 46 | + /** |
|
| 47 | + * Get the path to the dark (black) icon of this provider |
|
| 48 | + * |
|
| 49 | + * @return String |
|
| 50 | + * |
|
| 51 | + * @since 15.0.0 |
|
| 52 | + */ |
|
| 53 | + public function getDarkIcon(): String; |
|
| 54 | 54 | |
| 55 | 55 | } |