@@ -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 | } |
@@ -38,90 +38,90 @@ |
||
38 | 38 | |
39 | 39 | class Admin implements ISettings { |
40 | 40 | |
41 | - /** @var IL10N */ |
|
42 | - private $l; |
|
43 | - |
|
44 | - /** @var ILogger */ |
|
45 | - private $logger; |
|
46 | - |
|
47 | - /** @var IUserSession */ |
|
48 | - private $userSession; |
|
49 | - |
|
50 | - /** @var IConfig */ |
|
51 | - private $config; |
|
52 | - |
|
53 | - /** @var IUserManager */ |
|
54 | - private $userManager; |
|
55 | - |
|
56 | - /** @var ISession */ |
|
57 | - private $session; |
|
58 | - |
|
59 | - public function __construct( |
|
60 | - IL10N $l, |
|
61 | - ILogger $logger, |
|
62 | - IUserSession $userSession, |
|
63 | - IConfig $config, |
|
64 | - IUserManager $userManager, |
|
65 | - ISession $session |
|
66 | - ) { |
|
67 | - $this->l = $l; |
|
68 | - $this->logger = $logger; |
|
69 | - $this->userSession = $userSession; |
|
70 | - $this->config = $config; |
|
71 | - $this->userManager = $userManager; |
|
72 | - $this->session = $session; |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * @return TemplateResponse |
|
77 | - */ |
|
78 | - public function getForm() { |
|
79 | - $crypt = new Crypt( |
|
80 | - $this->logger, |
|
81 | - $this->userSession, |
|
82 | - $this->config, |
|
83 | - $this->l); |
|
84 | - |
|
85 | - $util = new Util( |
|
86 | - new View(), |
|
87 | - $crypt, |
|
88 | - $this->logger, |
|
89 | - $this->userSession, |
|
90 | - $this->config, |
|
91 | - $this->userManager); |
|
92 | - |
|
93 | - // Check if an adminRecovery account is enabled for recovering files after lost pwd |
|
94 | - $recoveryAdminEnabled = $this->config->getAppValue('encryption', 'recoveryAdminEnabled', '0'); |
|
95 | - $session = new Session($this->session); |
|
96 | - |
|
97 | - $encryptHomeStorage = $util->shouldEncryptHomeStorage(); |
|
98 | - |
|
99 | - $parameters = [ |
|
100 | - 'recoveryEnabled' => $recoveryAdminEnabled, |
|
101 | - 'initStatus' => $session->getStatus(), |
|
102 | - 'encryptHomeStorage' => $encryptHomeStorage, |
|
103 | - 'masterKeyEnabled' => $util->isMasterKeyEnabled(), |
|
104 | - ]; |
|
105 | - |
|
106 | - return new TemplateResponse('encryption', 'settings-admin', $parameters, ''); |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * @return string the section ID, e.g. 'sharing' |
|
111 | - */ |
|
112 | - public function getSection() { |
|
113 | - return 'security'; |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * @return int whether the form should be rather on the top or bottom of |
|
118 | - * the admin section. The forms are arranged in ascending order of the |
|
119 | - * priority values. It is required to return a value between 0 and 100. |
|
120 | - * |
|
121 | - * E.g.: 70 |
|
122 | - */ |
|
123 | - public function getPriority() { |
|
124 | - return 11; |
|
125 | - } |
|
41 | + /** @var IL10N */ |
|
42 | + private $l; |
|
43 | + |
|
44 | + /** @var ILogger */ |
|
45 | + private $logger; |
|
46 | + |
|
47 | + /** @var IUserSession */ |
|
48 | + private $userSession; |
|
49 | + |
|
50 | + /** @var IConfig */ |
|
51 | + private $config; |
|
52 | + |
|
53 | + /** @var IUserManager */ |
|
54 | + private $userManager; |
|
55 | + |
|
56 | + /** @var ISession */ |
|
57 | + private $session; |
|
58 | + |
|
59 | + public function __construct( |
|
60 | + IL10N $l, |
|
61 | + ILogger $logger, |
|
62 | + IUserSession $userSession, |
|
63 | + IConfig $config, |
|
64 | + IUserManager $userManager, |
|
65 | + ISession $session |
|
66 | + ) { |
|
67 | + $this->l = $l; |
|
68 | + $this->logger = $logger; |
|
69 | + $this->userSession = $userSession; |
|
70 | + $this->config = $config; |
|
71 | + $this->userManager = $userManager; |
|
72 | + $this->session = $session; |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * @return TemplateResponse |
|
77 | + */ |
|
78 | + public function getForm() { |
|
79 | + $crypt = new Crypt( |
|
80 | + $this->logger, |
|
81 | + $this->userSession, |
|
82 | + $this->config, |
|
83 | + $this->l); |
|
84 | + |
|
85 | + $util = new Util( |
|
86 | + new View(), |
|
87 | + $crypt, |
|
88 | + $this->logger, |
|
89 | + $this->userSession, |
|
90 | + $this->config, |
|
91 | + $this->userManager); |
|
92 | + |
|
93 | + // Check if an adminRecovery account is enabled for recovering files after lost pwd |
|
94 | + $recoveryAdminEnabled = $this->config->getAppValue('encryption', 'recoveryAdminEnabled', '0'); |
|
95 | + $session = new Session($this->session); |
|
96 | + |
|
97 | + $encryptHomeStorage = $util->shouldEncryptHomeStorage(); |
|
98 | + |
|
99 | + $parameters = [ |
|
100 | + 'recoveryEnabled' => $recoveryAdminEnabled, |
|
101 | + 'initStatus' => $session->getStatus(), |
|
102 | + 'encryptHomeStorage' => $encryptHomeStorage, |
|
103 | + 'masterKeyEnabled' => $util->isMasterKeyEnabled(), |
|
104 | + ]; |
|
105 | + |
|
106 | + return new TemplateResponse('encryption', 'settings-admin', $parameters, ''); |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * @return string the section ID, e.g. 'sharing' |
|
111 | + */ |
|
112 | + public function getSection() { |
|
113 | + return 'security'; |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * @return int whether the form should be rather on the top or bottom of |
|
118 | + * the admin section. The forms are arranged in ascending order of the |
|
119 | + * priority values. It is required to return a value between 0 and 100. |
|
120 | + * |
|
121 | + * E.g.: 70 |
|
122 | + */ |
|
123 | + public function getPriority() { |
|
124 | + return 11; |
|
125 | + } |
|
126 | 126 | |
127 | 127 | } |
@@ -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 | } |
@@ -25,23 +25,23 @@ |
||
25 | 25 | |
26 | 26 | class GroupwareBundle extends Bundle { |
27 | 27 | |
28 | - /** |
|
29 | - * {@inheritDoc} |
|
30 | - */ |
|
31 | - public function getName() { |
|
32 | - return (string)$this->l10n->t('Groupware bundle'); |
|
33 | - } |
|
28 | + /** |
|
29 | + * {@inheritDoc} |
|
30 | + */ |
|
31 | + public function getName() { |
|
32 | + return (string)$this->l10n->t('Groupware bundle'); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * {@inheritDoc} |
|
37 | - */ |
|
38 | - public function getAppIdentifiers() { |
|
39 | - return [ |
|
40 | - 'calendar', |
|
41 | - 'contacts', |
|
42 | - 'deck', |
|
43 | - 'mail' |
|
44 | - ]; |
|
45 | - } |
|
35 | + /** |
|
36 | + * {@inheritDoc} |
|
37 | + */ |
|
38 | + public function getAppIdentifiers() { |
|
39 | + return [ |
|
40 | + 'calendar', |
|
41 | + 'contacts', |
|
42 | + 'deck', |
|
43 | + 'mail' |
|
44 | + ]; |
|
45 | + } |
|
46 | 46 | |
47 | 47 | } |
@@ -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 | } |
@@ -31,44 +31,44 @@ |
||
31 | 31 | use Symfony\Component\Console\Output\OutputInterface; |
32 | 32 | |
33 | 33 | class Delete extends Base { |
34 | - /** @var IGroupManager */ |
|
35 | - protected $groupManager; |
|
34 | + /** @var IGroupManager */ |
|
35 | + protected $groupManager; |
|
36 | 36 | |
37 | - /** |
|
38 | - * @param IGroupManager $groupManager |
|
39 | - */ |
|
40 | - public function __construct(IGroupManager $groupManager) { |
|
41 | - $this->groupManager = $groupManager; |
|
42 | - parent::__construct(); |
|
43 | - } |
|
37 | + /** |
|
38 | + * @param IGroupManager $groupManager |
|
39 | + */ |
|
40 | + public function __construct(IGroupManager $groupManager) { |
|
41 | + $this->groupManager = $groupManager; |
|
42 | + parent::__construct(); |
|
43 | + } |
|
44 | 44 | |
45 | - protected function configure() { |
|
46 | - $this |
|
47 | - ->setName('group:delete') |
|
48 | - ->setDescription('Remove a group') |
|
49 | - ->addArgument( |
|
50 | - 'groupid', |
|
51 | - InputArgument::REQUIRED, |
|
52 | - 'Group name' |
|
53 | - ); |
|
54 | - } |
|
45 | + protected function configure() { |
|
46 | + $this |
|
47 | + ->setName('group:delete') |
|
48 | + ->setDescription('Remove a group') |
|
49 | + ->addArgument( |
|
50 | + 'groupid', |
|
51 | + InputArgument::REQUIRED, |
|
52 | + 'Group name' |
|
53 | + ); |
|
54 | + } |
|
55 | 55 | |
56 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
57 | - $gid = $input->getArgument('groupid'); |
|
58 | - if ($gid === 'admin') { |
|
59 | - $output->writeln('<error>Group "' . $gid . '" could not be deleted.</error>'); |
|
60 | - return 1; |
|
61 | - } |
|
62 | - if (! $this->groupManager->groupExists($gid)) { |
|
63 | - $output->writeln('<error>Group "' . $gid . '" does not exist.</error>'); |
|
64 | - return 1; |
|
65 | - } |
|
66 | - $group = $this->groupManager->get($gid); |
|
67 | - if ($group->delete()) { |
|
68 | - $output->writeln('Group "' . $gid . '" was removed'); |
|
69 | - } else { |
|
70 | - $output->writeln('<error>Group "' . $gid . '" could not be deleted. Please check the logs.</error>'); |
|
71 | - return 1; |
|
72 | - } |
|
73 | - } |
|
56 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
57 | + $gid = $input->getArgument('groupid'); |
|
58 | + if ($gid === 'admin') { |
|
59 | + $output->writeln('<error>Group "' . $gid . '" could not be deleted.</error>'); |
|
60 | + return 1; |
|
61 | + } |
|
62 | + if (! $this->groupManager->groupExists($gid)) { |
|
63 | + $output->writeln('<error>Group "' . $gid . '" does not exist.</error>'); |
|
64 | + return 1; |
|
65 | + } |
|
66 | + $group = $this->groupManager->get($gid); |
|
67 | + if ($group->delete()) { |
|
68 | + $output->writeln('Group "' . $gid . '" was removed'); |
|
69 | + } else { |
|
70 | + $output->writeln('<error>Group "' . $gid . '" could not be deleted. Please check the logs.</error>'); |
|
71 | + return 1; |
|
72 | + } |
|
73 | + } |
|
74 | 74 | } |
@@ -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 | } |
@@ -43,367 +43,367 @@ |
||
43 | 43 | * Cache mounts points per user in the cache so we can easilly look them up |
44 | 44 | */ |
45 | 45 | class UserMountCache implements IUserMountCache { |
46 | - /** |
|
47 | - * @var IDBConnection |
|
48 | - */ |
|
49 | - private $connection; |
|
50 | - |
|
51 | - /** |
|
52 | - * @var IUserManager |
|
53 | - */ |
|
54 | - private $userManager; |
|
55 | - |
|
56 | - /** |
|
57 | - * Cached mount info. |
|
58 | - * Map of $userId to ICachedMountInfo. |
|
59 | - * |
|
60 | - * @var ICache |
|
61 | - **/ |
|
62 | - private $mountsForUsers; |
|
63 | - |
|
64 | - /** |
|
65 | - * @var ILogger |
|
66 | - */ |
|
67 | - private $logger; |
|
68 | - |
|
69 | - /** |
|
70 | - * @var ICache |
|
71 | - */ |
|
72 | - private $cacheInfoCache; |
|
73 | - |
|
74 | - /** |
|
75 | - * UserMountCache constructor. |
|
76 | - * |
|
77 | - * @param IDBConnection $connection |
|
78 | - * @param IUserManager $userManager |
|
79 | - * @param ILogger $logger |
|
80 | - */ |
|
81 | - public function __construct(IDBConnection $connection, IUserManager $userManager, ILogger $logger) { |
|
82 | - $this->connection = $connection; |
|
83 | - $this->userManager = $userManager; |
|
84 | - $this->logger = $logger; |
|
85 | - $this->cacheInfoCache = new CappedMemoryCache(); |
|
86 | - $this->mountsForUsers = new CappedMemoryCache(); |
|
87 | - } |
|
88 | - |
|
89 | - public function registerMounts(IUser $user, array $mounts) { |
|
90 | - // filter out non-proper storages coming from unit tests |
|
91 | - $mounts = array_filter($mounts, function (IMountPoint $mount) { |
|
92 | - return $mount instanceof SharedMount || $mount->getStorage() && $mount->getStorage()->getCache(); |
|
93 | - }); |
|
94 | - /** @var ICachedMountInfo[] $newMounts */ |
|
95 | - $newMounts = array_map(function (IMountPoint $mount) use ($user) { |
|
96 | - // filter out any storages which aren't scanned yet since we aren't interested in files from those storages (yet) |
|
97 | - if ($mount->getStorageRootId() === -1) { |
|
98 | - return null; |
|
99 | - } else { |
|
100 | - return new LazyStorageMountInfo($user, $mount); |
|
101 | - } |
|
102 | - }, $mounts); |
|
103 | - $newMounts = array_values(array_filter($newMounts)); |
|
104 | - $newMountRootIds = array_map(function (ICachedMountInfo $mount) { |
|
105 | - return $mount->getRootId(); |
|
106 | - }, $newMounts); |
|
107 | - $newMounts = array_combine($newMountRootIds, $newMounts); |
|
108 | - |
|
109 | - $cachedMounts = $this->getMountsForUser($user); |
|
110 | - $cachedMountRootIds = array_map(function (ICachedMountInfo $mount) { |
|
111 | - return $mount->getRootId(); |
|
112 | - }, $cachedMounts); |
|
113 | - $cachedMounts = array_combine($cachedMountRootIds, $cachedMounts); |
|
114 | - |
|
115 | - $addedMounts = []; |
|
116 | - $removedMounts = []; |
|
117 | - |
|
118 | - foreach ($newMounts as $rootId => $newMount) { |
|
119 | - if (!isset($cachedMounts[$rootId])) { |
|
120 | - $addedMounts[] = $newMount; |
|
121 | - } |
|
122 | - } |
|
123 | - |
|
124 | - foreach ($cachedMounts as $rootId => $cachedMount) { |
|
125 | - if (!isset($newMounts[$rootId])) { |
|
126 | - $removedMounts[] = $cachedMount; |
|
127 | - } |
|
128 | - } |
|
129 | - |
|
130 | - $changedMounts = $this->findChangedMounts($newMounts, $cachedMounts); |
|
131 | - |
|
132 | - foreach ($addedMounts as $mount) { |
|
133 | - $this->addToCache($mount); |
|
134 | - $this->mountsForUsers[$user->getUID()][] = $mount; |
|
135 | - } |
|
136 | - foreach ($removedMounts as $mount) { |
|
137 | - $this->removeFromCache($mount); |
|
138 | - $index = array_search($mount, $this->mountsForUsers[$user->getUID()]); |
|
139 | - unset($this->mountsForUsers[$user->getUID()][$index]); |
|
140 | - } |
|
141 | - foreach ($changedMounts as $mount) { |
|
142 | - $this->updateCachedMount($mount); |
|
143 | - } |
|
144 | - } |
|
145 | - |
|
146 | - /** |
|
147 | - * @param ICachedMountInfo[] $newMounts |
|
148 | - * @param ICachedMountInfo[] $cachedMounts |
|
149 | - * @return ICachedMountInfo[] |
|
150 | - */ |
|
151 | - private function findChangedMounts(array $newMounts, array $cachedMounts) { |
|
152 | - $new = []; |
|
153 | - foreach ($newMounts as $mount) { |
|
154 | - $new[$mount->getRootId()] = $mount; |
|
155 | - } |
|
156 | - $changed = []; |
|
157 | - foreach ($cachedMounts as $cachedMount) { |
|
158 | - $rootId = $cachedMount->getRootId(); |
|
159 | - if (isset($new[$rootId])) { |
|
160 | - $newMount = $new[$rootId]; |
|
161 | - if ( |
|
162 | - $newMount->getMountPoint() !== $cachedMount->getMountPoint() || |
|
163 | - $newMount->getStorageId() !== $cachedMount->getStorageId() || |
|
164 | - $newMount->getMountId() !== $cachedMount->getMountId() |
|
165 | - ) { |
|
166 | - $changed[] = $newMount; |
|
167 | - } |
|
168 | - } |
|
169 | - } |
|
170 | - return $changed; |
|
171 | - } |
|
172 | - |
|
173 | - private function addToCache(ICachedMountInfo $mount) { |
|
174 | - if ($mount->getStorageId() !== -1) { |
|
175 | - $this->connection->insertIfNotExist('*PREFIX*mounts', [ |
|
176 | - 'storage_id' => $mount->getStorageId(), |
|
177 | - 'root_id' => $mount->getRootId(), |
|
178 | - 'user_id' => $mount->getUser()->getUID(), |
|
179 | - 'mount_point' => $mount->getMountPoint(), |
|
180 | - 'mount_id' => $mount->getMountId() |
|
181 | - ], ['root_id', 'user_id']); |
|
182 | - } else { |
|
183 | - // in some cases this is legitimate, like orphaned shares |
|
184 | - $this->logger->debug('Could not get storage info for mount at ' . $mount->getMountPoint()); |
|
185 | - } |
|
186 | - } |
|
187 | - |
|
188 | - private function updateCachedMount(ICachedMountInfo $mount) { |
|
189 | - $builder = $this->connection->getQueryBuilder(); |
|
190 | - |
|
191 | - $query = $builder->update('mounts') |
|
192 | - ->set('storage_id', $builder->createNamedParameter($mount->getStorageId())) |
|
193 | - ->set('mount_point', $builder->createNamedParameter($mount->getMountPoint())) |
|
194 | - ->set('mount_id', $builder->createNamedParameter($mount->getMountId(), IQueryBuilder::PARAM_INT)) |
|
195 | - ->where($builder->expr()->eq('user_id', $builder->createNamedParameter($mount->getUser()->getUID()))) |
|
196 | - ->andWhere($builder->expr()->eq('root_id', $builder->createNamedParameter($mount->getRootId(), IQueryBuilder::PARAM_INT))); |
|
197 | - |
|
198 | - $query->execute(); |
|
199 | - } |
|
200 | - |
|
201 | - private function removeFromCache(ICachedMountInfo $mount) { |
|
202 | - $builder = $this->connection->getQueryBuilder(); |
|
203 | - |
|
204 | - $query = $builder->delete('mounts') |
|
205 | - ->where($builder->expr()->eq('user_id', $builder->createNamedParameter($mount->getUser()->getUID()))) |
|
206 | - ->andWhere($builder->expr()->eq('root_id', $builder->createNamedParameter($mount->getRootId(), IQueryBuilder::PARAM_INT))); |
|
207 | - $query->execute(); |
|
208 | - } |
|
209 | - |
|
210 | - private function dbRowToMountInfo(array $row) { |
|
211 | - $user = $this->userManager->get($row['user_id']); |
|
212 | - if (is_null($user)) { |
|
213 | - return null; |
|
214 | - } |
|
215 | - $mount_id = $row['mount_id']; |
|
216 | - if (!is_null($mount_id)) { |
|
217 | - $mount_id = (int)$mount_id; |
|
218 | - } |
|
219 | - return new CachedMountInfo($user, (int)$row['storage_id'], (int)$row['root_id'], $row['mount_point'], $mount_id, isset($row['path']) ? $row['path'] : ''); |
|
220 | - } |
|
221 | - |
|
222 | - /** |
|
223 | - * @param IUser $user |
|
224 | - * @return ICachedMountInfo[] |
|
225 | - */ |
|
226 | - public function getMountsForUser(IUser $user) { |
|
227 | - if (!isset($this->mountsForUsers[$user->getUID()])) { |
|
228 | - $builder = $this->connection->getQueryBuilder(); |
|
229 | - $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path') |
|
230 | - ->from('mounts', 'm') |
|
231 | - ->innerJoin('m', 'filecache', 'f', $builder->expr()->eq('m.root_id', 'f.fileid')) |
|
232 | - ->where($builder->expr()->eq('user_id', $builder->createPositionalParameter($user->getUID()))); |
|
233 | - |
|
234 | - $rows = $query->execute()->fetchAll(); |
|
235 | - |
|
236 | - $this->mountsForUsers[$user->getUID()] = array_filter(array_map([$this, 'dbRowToMountInfo'], $rows)); |
|
237 | - } |
|
238 | - return $this->mountsForUsers[$user->getUID()]; |
|
239 | - } |
|
240 | - |
|
241 | - /** |
|
242 | - * @param int $numericStorageId |
|
243 | - * @param string|null $user limit the results to a single user |
|
244 | - * @return CachedMountInfo[] |
|
245 | - */ |
|
246 | - public function getMountsForStorageId($numericStorageId, $user = null) { |
|
247 | - $builder = $this->connection->getQueryBuilder(); |
|
248 | - $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path') |
|
249 | - ->from('mounts', 'm') |
|
250 | - ->innerJoin('m', 'filecache', 'f', $builder->expr()->eq('m.root_id', 'f.fileid')) |
|
251 | - ->where($builder->expr()->eq('storage_id', $builder->createPositionalParameter($numericStorageId, IQueryBuilder::PARAM_INT))); |
|
252 | - |
|
253 | - if ($user) { |
|
254 | - $query->andWhere($builder->expr()->eq('user_id', $builder->createPositionalParameter($user))); |
|
255 | - } |
|
256 | - |
|
257 | - $rows = $query->execute()->fetchAll(); |
|
258 | - |
|
259 | - return array_filter(array_map([$this, 'dbRowToMountInfo'], $rows)); |
|
260 | - } |
|
261 | - |
|
262 | - /** |
|
263 | - * @param int $rootFileId |
|
264 | - * @return CachedMountInfo[] |
|
265 | - */ |
|
266 | - public function getMountsForRootId($rootFileId) { |
|
267 | - $builder = $this->connection->getQueryBuilder(); |
|
268 | - $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path') |
|
269 | - ->from('mounts', 'm') |
|
270 | - ->innerJoin('m', 'filecache', 'f', $builder->expr()->eq('m.root_id', 'f.fileid')) |
|
271 | - ->where($builder->expr()->eq('root_id', $builder->createPositionalParameter($rootFileId, IQueryBuilder::PARAM_INT))); |
|
272 | - |
|
273 | - $rows = $query->execute()->fetchAll(); |
|
274 | - |
|
275 | - return array_filter(array_map([$this, 'dbRowToMountInfo'], $rows)); |
|
276 | - } |
|
277 | - |
|
278 | - /** |
|
279 | - * @param $fileId |
|
280 | - * @return array |
|
281 | - * @throws \OCP\Files\NotFoundException |
|
282 | - */ |
|
283 | - private function getCacheInfoFromFileId($fileId) { |
|
284 | - if (!isset($this->cacheInfoCache[$fileId])) { |
|
285 | - $builder = $this->connection->getQueryBuilder(); |
|
286 | - $query = $builder->select('storage', 'path', 'mimetype') |
|
287 | - ->from('filecache') |
|
288 | - ->where($builder->expr()->eq('fileid', $builder->createNamedParameter($fileId, IQueryBuilder::PARAM_INT))); |
|
289 | - |
|
290 | - $row = $query->execute()->fetch(); |
|
291 | - if (is_array($row)) { |
|
292 | - $this->cacheInfoCache[$fileId] = [ |
|
293 | - (int)$row['storage'], |
|
294 | - $row['path'], |
|
295 | - (int)$row['mimetype'] |
|
296 | - ]; |
|
297 | - } else { |
|
298 | - throw new NotFoundException('File with id "' . $fileId . '" not found'); |
|
299 | - } |
|
300 | - } |
|
301 | - return $this->cacheInfoCache[$fileId]; |
|
302 | - } |
|
303 | - |
|
304 | - /** |
|
305 | - * @param int $fileId |
|
306 | - * @param string|null $user optionally restrict the results to a single user |
|
307 | - * @return ICachedMountFileInfo[] |
|
308 | - * @since 9.0.0 |
|
309 | - */ |
|
310 | - public function getMountsForFileId($fileId, $user = null) { |
|
311 | - try { |
|
312 | - list($storageId, $internalPath) = $this->getCacheInfoFromFileId($fileId); |
|
313 | - } catch (NotFoundException $e) { |
|
314 | - return []; |
|
315 | - } |
|
316 | - $mountsForStorage = $this->getMountsForStorageId($storageId, $user); |
|
317 | - |
|
318 | - // filter mounts that are from the same storage but a different directory |
|
319 | - $filteredMounts = array_filter($mountsForStorage, function (ICachedMountInfo $mount) use ($internalPath, $fileId) { |
|
320 | - if ($fileId === $mount->getRootId()) { |
|
321 | - return true; |
|
322 | - } |
|
323 | - $internalMountPath = $mount->getRootInternalPath(); |
|
324 | - |
|
325 | - return $internalMountPath === '' || substr($internalPath, 0, strlen($internalMountPath) + 1) === $internalMountPath . '/'; |
|
326 | - }); |
|
327 | - |
|
328 | - return array_map(function (ICachedMountInfo $mount) use ($internalPath) { |
|
329 | - return new CachedMountFileInfo( |
|
330 | - $mount->getUser(), |
|
331 | - $mount->getStorageId(), |
|
332 | - $mount->getRootId(), |
|
333 | - $mount->getMountPoint(), |
|
334 | - $mount->getMountId(), |
|
335 | - $mount->getRootInternalPath(), |
|
336 | - $internalPath |
|
337 | - ); |
|
338 | - }, $filteredMounts); |
|
339 | - } |
|
340 | - |
|
341 | - /** |
|
342 | - * Remove all cached mounts for a user |
|
343 | - * |
|
344 | - * @param IUser $user |
|
345 | - */ |
|
346 | - public function removeUserMounts(IUser $user) { |
|
347 | - $builder = $this->connection->getQueryBuilder(); |
|
348 | - |
|
349 | - $query = $builder->delete('mounts') |
|
350 | - ->where($builder->expr()->eq('user_id', $builder->createNamedParameter($user->getUID()))); |
|
351 | - $query->execute(); |
|
352 | - } |
|
353 | - |
|
354 | - public function removeUserStorageMount($storageId, $userId) { |
|
355 | - $builder = $this->connection->getQueryBuilder(); |
|
356 | - |
|
357 | - $query = $builder->delete('mounts') |
|
358 | - ->where($builder->expr()->eq('user_id', $builder->createNamedParameter($userId))) |
|
359 | - ->andWhere($builder->expr()->eq('storage_id', $builder->createNamedParameter($storageId, IQueryBuilder::PARAM_INT))); |
|
360 | - $query->execute(); |
|
361 | - } |
|
362 | - |
|
363 | - public function remoteStorageMounts($storageId) { |
|
364 | - $builder = $this->connection->getQueryBuilder(); |
|
365 | - |
|
366 | - $query = $builder->delete('mounts') |
|
367 | - ->where($builder->expr()->eq('storage_id', $builder->createNamedParameter($storageId, IQueryBuilder::PARAM_INT))); |
|
368 | - $query->execute(); |
|
369 | - } |
|
370 | - |
|
371 | - /** |
|
372 | - * @param array $users |
|
373 | - * @return array |
|
374 | - * @suppress SqlInjectionChecker |
|
375 | - */ |
|
376 | - public function getUsedSpaceForUsers(array $users) { |
|
377 | - $builder = $this->connection->getQueryBuilder(); |
|
378 | - |
|
379 | - $slash = $builder->createNamedParameter('/'); |
|
380 | - |
|
381 | - $mountPoint = $builder->func()->concat( |
|
382 | - $builder->func()->concat($slash, 'user_id'), |
|
383 | - $slash |
|
384 | - ); |
|
385 | - |
|
386 | - $userIds = array_map(function (IUser $user) { |
|
387 | - return $user->getUID(); |
|
388 | - }, $users); |
|
389 | - |
|
390 | - $query = $builder->select('m.user_id', 'f.size') |
|
391 | - ->from('mounts', 'm') |
|
392 | - ->innerJoin('m', 'filecache', 'f', |
|
393 | - $builder->expr()->andX( |
|
394 | - $builder->expr()->eq('m.storage_id', 'f.storage'), |
|
395 | - $builder->expr()->eq('f.path_hash', $builder->createNamedParameter(md5('files'))) |
|
396 | - )) |
|
397 | - ->where($builder->expr()->eq('m.mount_point', $mountPoint)) |
|
398 | - ->andWhere($builder->expr()->in('m.user_id', $builder->createNamedParameter($userIds, IQueryBuilder::PARAM_STR_ARRAY))); |
|
399 | - |
|
400 | - $result = $query->execute(); |
|
401 | - |
|
402 | - $results = []; |
|
403 | - while ($row = $result->fetch()) { |
|
404 | - $results[$row['user_id']] = $row['size']; |
|
405 | - } |
|
406 | - $result->closeCursor(); |
|
407 | - return $results; |
|
408 | - } |
|
46 | + /** |
|
47 | + * @var IDBConnection |
|
48 | + */ |
|
49 | + private $connection; |
|
50 | + |
|
51 | + /** |
|
52 | + * @var IUserManager |
|
53 | + */ |
|
54 | + private $userManager; |
|
55 | + |
|
56 | + /** |
|
57 | + * Cached mount info. |
|
58 | + * Map of $userId to ICachedMountInfo. |
|
59 | + * |
|
60 | + * @var ICache |
|
61 | + **/ |
|
62 | + private $mountsForUsers; |
|
63 | + |
|
64 | + /** |
|
65 | + * @var ILogger |
|
66 | + */ |
|
67 | + private $logger; |
|
68 | + |
|
69 | + /** |
|
70 | + * @var ICache |
|
71 | + */ |
|
72 | + private $cacheInfoCache; |
|
73 | + |
|
74 | + /** |
|
75 | + * UserMountCache constructor. |
|
76 | + * |
|
77 | + * @param IDBConnection $connection |
|
78 | + * @param IUserManager $userManager |
|
79 | + * @param ILogger $logger |
|
80 | + */ |
|
81 | + public function __construct(IDBConnection $connection, IUserManager $userManager, ILogger $logger) { |
|
82 | + $this->connection = $connection; |
|
83 | + $this->userManager = $userManager; |
|
84 | + $this->logger = $logger; |
|
85 | + $this->cacheInfoCache = new CappedMemoryCache(); |
|
86 | + $this->mountsForUsers = new CappedMemoryCache(); |
|
87 | + } |
|
88 | + |
|
89 | + public function registerMounts(IUser $user, array $mounts) { |
|
90 | + // filter out non-proper storages coming from unit tests |
|
91 | + $mounts = array_filter($mounts, function (IMountPoint $mount) { |
|
92 | + return $mount instanceof SharedMount || $mount->getStorage() && $mount->getStorage()->getCache(); |
|
93 | + }); |
|
94 | + /** @var ICachedMountInfo[] $newMounts */ |
|
95 | + $newMounts = array_map(function (IMountPoint $mount) use ($user) { |
|
96 | + // filter out any storages which aren't scanned yet since we aren't interested in files from those storages (yet) |
|
97 | + if ($mount->getStorageRootId() === -1) { |
|
98 | + return null; |
|
99 | + } else { |
|
100 | + return new LazyStorageMountInfo($user, $mount); |
|
101 | + } |
|
102 | + }, $mounts); |
|
103 | + $newMounts = array_values(array_filter($newMounts)); |
|
104 | + $newMountRootIds = array_map(function (ICachedMountInfo $mount) { |
|
105 | + return $mount->getRootId(); |
|
106 | + }, $newMounts); |
|
107 | + $newMounts = array_combine($newMountRootIds, $newMounts); |
|
108 | + |
|
109 | + $cachedMounts = $this->getMountsForUser($user); |
|
110 | + $cachedMountRootIds = array_map(function (ICachedMountInfo $mount) { |
|
111 | + return $mount->getRootId(); |
|
112 | + }, $cachedMounts); |
|
113 | + $cachedMounts = array_combine($cachedMountRootIds, $cachedMounts); |
|
114 | + |
|
115 | + $addedMounts = []; |
|
116 | + $removedMounts = []; |
|
117 | + |
|
118 | + foreach ($newMounts as $rootId => $newMount) { |
|
119 | + if (!isset($cachedMounts[$rootId])) { |
|
120 | + $addedMounts[] = $newMount; |
|
121 | + } |
|
122 | + } |
|
123 | + |
|
124 | + foreach ($cachedMounts as $rootId => $cachedMount) { |
|
125 | + if (!isset($newMounts[$rootId])) { |
|
126 | + $removedMounts[] = $cachedMount; |
|
127 | + } |
|
128 | + } |
|
129 | + |
|
130 | + $changedMounts = $this->findChangedMounts($newMounts, $cachedMounts); |
|
131 | + |
|
132 | + foreach ($addedMounts as $mount) { |
|
133 | + $this->addToCache($mount); |
|
134 | + $this->mountsForUsers[$user->getUID()][] = $mount; |
|
135 | + } |
|
136 | + foreach ($removedMounts as $mount) { |
|
137 | + $this->removeFromCache($mount); |
|
138 | + $index = array_search($mount, $this->mountsForUsers[$user->getUID()]); |
|
139 | + unset($this->mountsForUsers[$user->getUID()][$index]); |
|
140 | + } |
|
141 | + foreach ($changedMounts as $mount) { |
|
142 | + $this->updateCachedMount($mount); |
|
143 | + } |
|
144 | + } |
|
145 | + |
|
146 | + /** |
|
147 | + * @param ICachedMountInfo[] $newMounts |
|
148 | + * @param ICachedMountInfo[] $cachedMounts |
|
149 | + * @return ICachedMountInfo[] |
|
150 | + */ |
|
151 | + private function findChangedMounts(array $newMounts, array $cachedMounts) { |
|
152 | + $new = []; |
|
153 | + foreach ($newMounts as $mount) { |
|
154 | + $new[$mount->getRootId()] = $mount; |
|
155 | + } |
|
156 | + $changed = []; |
|
157 | + foreach ($cachedMounts as $cachedMount) { |
|
158 | + $rootId = $cachedMount->getRootId(); |
|
159 | + if (isset($new[$rootId])) { |
|
160 | + $newMount = $new[$rootId]; |
|
161 | + if ( |
|
162 | + $newMount->getMountPoint() !== $cachedMount->getMountPoint() || |
|
163 | + $newMount->getStorageId() !== $cachedMount->getStorageId() || |
|
164 | + $newMount->getMountId() !== $cachedMount->getMountId() |
|
165 | + ) { |
|
166 | + $changed[] = $newMount; |
|
167 | + } |
|
168 | + } |
|
169 | + } |
|
170 | + return $changed; |
|
171 | + } |
|
172 | + |
|
173 | + private function addToCache(ICachedMountInfo $mount) { |
|
174 | + if ($mount->getStorageId() !== -1) { |
|
175 | + $this->connection->insertIfNotExist('*PREFIX*mounts', [ |
|
176 | + 'storage_id' => $mount->getStorageId(), |
|
177 | + 'root_id' => $mount->getRootId(), |
|
178 | + 'user_id' => $mount->getUser()->getUID(), |
|
179 | + 'mount_point' => $mount->getMountPoint(), |
|
180 | + 'mount_id' => $mount->getMountId() |
|
181 | + ], ['root_id', 'user_id']); |
|
182 | + } else { |
|
183 | + // in some cases this is legitimate, like orphaned shares |
|
184 | + $this->logger->debug('Could not get storage info for mount at ' . $mount->getMountPoint()); |
|
185 | + } |
|
186 | + } |
|
187 | + |
|
188 | + private function updateCachedMount(ICachedMountInfo $mount) { |
|
189 | + $builder = $this->connection->getQueryBuilder(); |
|
190 | + |
|
191 | + $query = $builder->update('mounts') |
|
192 | + ->set('storage_id', $builder->createNamedParameter($mount->getStorageId())) |
|
193 | + ->set('mount_point', $builder->createNamedParameter($mount->getMountPoint())) |
|
194 | + ->set('mount_id', $builder->createNamedParameter($mount->getMountId(), IQueryBuilder::PARAM_INT)) |
|
195 | + ->where($builder->expr()->eq('user_id', $builder->createNamedParameter($mount->getUser()->getUID()))) |
|
196 | + ->andWhere($builder->expr()->eq('root_id', $builder->createNamedParameter($mount->getRootId(), IQueryBuilder::PARAM_INT))); |
|
197 | + |
|
198 | + $query->execute(); |
|
199 | + } |
|
200 | + |
|
201 | + private function removeFromCache(ICachedMountInfo $mount) { |
|
202 | + $builder = $this->connection->getQueryBuilder(); |
|
203 | + |
|
204 | + $query = $builder->delete('mounts') |
|
205 | + ->where($builder->expr()->eq('user_id', $builder->createNamedParameter($mount->getUser()->getUID()))) |
|
206 | + ->andWhere($builder->expr()->eq('root_id', $builder->createNamedParameter($mount->getRootId(), IQueryBuilder::PARAM_INT))); |
|
207 | + $query->execute(); |
|
208 | + } |
|
209 | + |
|
210 | + private function dbRowToMountInfo(array $row) { |
|
211 | + $user = $this->userManager->get($row['user_id']); |
|
212 | + if (is_null($user)) { |
|
213 | + return null; |
|
214 | + } |
|
215 | + $mount_id = $row['mount_id']; |
|
216 | + if (!is_null($mount_id)) { |
|
217 | + $mount_id = (int)$mount_id; |
|
218 | + } |
|
219 | + return new CachedMountInfo($user, (int)$row['storage_id'], (int)$row['root_id'], $row['mount_point'], $mount_id, isset($row['path']) ? $row['path'] : ''); |
|
220 | + } |
|
221 | + |
|
222 | + /** |
|
223 | + * @param IUser $user |
|
224 | + * @return ICachedMountInfo[] |
|
225 | + */ |
|
226 | + public function getMountsForUser(IUser $user) { |
|
227 | + if (!isset($this->mountsForUsers[$user->getUID()])) { |
|
228 | + $builder = $this->connection->getQueryBuilder(); |
|
229 | + $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path') |
|
230 | + ->from('mounts', 'm') |
|
231 | + ->innerJoin('m', 'filecache', 'f', $builder->expr()->eq('m.root_id', 'f.fileid')) |
|
232 | + ->where($builder->expr()->eq('user_id', $builder->createPositionalParameter($user->getUID()))); |
|
233 | + |
|
234 | + $rows = $query->execute()->fetchAll(); |
|
235 | + |
|
236 | + $this->mountsForUsers[$user->getUID()] = array_filter(array_map([$this, 'dbRowToMountInfo'], $rows)); |
|
237 | + } |
|
238 | + return $this->mountsForUsers[$user->getUID()]; |
|
239 | + } |
|
240 | + |
|
241 | + /** |
|
242 | + * @param int $numericStorageId |
|
243 | + * @param string|null $user limit the results to a single user |
|
244 | + * @return CachedMountInfo[] |
|
245 | + */ |
|
246 | + public function getMountsForStorageId($numericStorageId, $user = null) { |
|
247 | + $builder = $this->connection->getQueryBuilder(); |
|
248 | + $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path') |
|
249 | + ->from('mounts', 'm') |
|
250 | + ->innerJoin('m', 'filecache', 'f', $builder->expr()->eq('m.root_id', 'f.fileid')) |
|
251 | + ->where($builder->expr()->eq('storage_id', $builder->createPositionalParameter($numericStorageId, IQueryBuilder::PARAM_INT))); |
|
252 | + |
|
253 | + if ($user) { |
|
254 | + $query->andWhere($builder->expr()->eq('user_id', $builder->createPositionalParameter($user))); |
|
255 | + } |
|
256 | + |
|
257 | + $rows = $query->execute()->fetchAll(); |
|
258 | + |
|
259 | + return array_filter(array_map([$this, 'dbRowToMountInfo'], $rows)); |
|
260 | + } |
|
261 | + |
|
262 | + /** |
|
263 | + * @param int $rootFileId |
|
264 | + * @return CachedMountInfo[] |
|
265 | + */ |
|
266 | + public function getMountsForRootId($rootFileId) { |
|
267 | + $builder = $this->connection->getQueryBuilder(); |
|
268 | + $query = $builder->select('storage_id', 'root_id', 'user_id', 'mount_point', 'mount_id', 'f.path') |
|
269 | + ->from('mounts', 'm') |
|
270 | + ->innerJoin('m', 'filecache', 'f', $builder->expr()->eq('m.root_id', 'f.fileid')) |
|
271 | + ->where($builder->expr()->eq('root_id', $builder->createPositionalParameter($rootFileId, IQueryBuilder::PARAM_INT))); |
|
272 | + |
|
273 | + $rows = $query->execute()->fetchAll(); |
|
274 | + |
|
275 | + return array_filter(array_map([$this, 'dbRowToMountInfo'], $rows)); |
|
276 | + } |
|
277 | + |
|
278 | + /** |
|
279 | + * @param $fileId |
|
280 | + * @return array |
|
281 | + * @throws \OCP\Files\NotFoundException |
|
282 | + */ |
|
283 | + private function getCacheInfoFromFileId($fileId) { |
|
284 | + if (!isset($this->cacheInfoCache[$fileId])) { |
|
285 | + $builder = $this->connection->getQueryBuilder(); |
|
286 | + $query = $builder->select('storage', 'path', 'mimetype') |
|
287 | + ->from('filecache') |
|
288 | + ->where($builder->expr()->eq('fileid', $builder->createNamedParameter($fileId, IQueryBuilder::PARAM_INT))); |
|
289 | + |
|
290 | + $row = $query->execute()->fetch(); |
|
291 | + if (is_array($row)) { |
|
292 | + $this->cacheInfoCache[$fileId] = [ |
|
293 | + (int)$row['storage'], |
|
294 | + $row['path'], |
|
295 | + (int)$row['mimetype'] |
|
296 | + ]; |
|
297 | + } else { |
|
298 | + throw new NotFoundException('File with id "' . $fileId . '" not found'); |
|
299 | + } |
|
300 | + } |
|
301 | + return $this->cacheInfoCache[$fileId]; |
|
302 | + } |
|
303 | + |
|
304 | + /** |
|
305 | + * @param int $fileId |
|
306 | + * @param string|null $user optionally restrict the results to a single user |
|
307 | + * @return ICachedMountFileInfo[] |
|
308 | + * @since 9.0.0 |
|
309 | + */ |
|
310 | + public function getMountsForFileId($fileId, $user = null) { |
|
311 | + try { |
|
312 | + list($storageId, $internalPath) = $this->getCacheInfoFromFileId($fileId); |
|
313 | + } catch (NotFoundException $e) { |
|
314 | + return []; |
|
315 | + } |
|
316 | + $mountsForStorage = $this->getMountsForStorageId($storageId, $user); |
|
317 | + |
|
318 | + // filter mounts that are from the same storage but a different directory |
|
319 | + $filteredMounts = array_filter($mountsForStorage, function (ICachedMountInfo $mount) use ($internalPath, $fileId) { |
|
320 | + if ($fileId === $mount->getRootId()) { |
|
321 | + return true; |
|
322 | + } |
|
323 | + $internalMountPath = $mount->getRootInternalPath(); |
|
324 | + |
|
325 | + return $internalMountPath === '' || substr($internalPath, 0, strlen($internalMountPath) + 1) === $internalMountPath . '/'; |
|
326 | + }); |
|
327 | + |
|
328 | + return array_map(function (ICachedMountInfo $mount) use ($internalPath) { |
|
329 | + return new CachedMountFileInfo( |
|
330 | + $mount->getUser(), |
|
331 | + $mount->getStorageId(), |
|
332 | + $mount->getRootId(), |
|
333 | + $mount->getMountPoint(), |
|
334 | + $mount->getMountId(), |
|
335 | + $mount->getRootInternalPath(), |
|
336 | + $internalPath |
|
337 | + ); |
|
338 | + }, $filteredMounts); |
|
339 | + } |
|
340 | + |
|
341 | + /** |
|
342 | + * Remove all cached mounts for a user |
|
343 | + * |
|
344 | + * @param IUser $user |
|
345 | + */ |
|
346 | + public function removeUserMounts(IUser $user) { |
|
347 | + $builder = $this->connection->getQueryBuilder(); |
|
348 | + |
|
349 | + $query = $builder->delete('mounts') |
|
350 | + ->where($builder->expr()->eq('user_id', $builder->createNamedParameter($user->getUID()))); |
|
351 | + $query->execute(); |
|
352 | + } |
|
353 | + |
|
354 | + public function removeUserStorageMount($storageId, $userId) { |
|
355 | + $builder = $this->connection->getQueryBuilder(); |
|
356 | + |
|
357 | + $query = $builder->delete('mounts') |
|
358 | + ->where($builder->expr()->eq('user_id', $builder->createNamedParameter($userId))) |
|
359 | + ->andWhere($builder->expr()->eq('storage_id', $builder->createNamedParameter($storageId, IQueryBuilder::PARAM_INT))); |
|
360 | + $query->execute(); |
|
361 | + } |
|
362 | + |
|
363 | + public function remoteStorageMounts($storageId) { |
|
364 | + $builder = $this->connection->getQueryBuilder(); |
|
365 | + |
|
366 | + $query = $builder->delete('mounts') |
|
367 | + ->where($builder->expr()->eq('storage_id', $builder->createNamedParameter($storageId, IQueryBuilder::PARAM_INT))); |
|
368 | + $query->execute(); |
|
369 | + } |
|
370 | + |
|
371 | + /** |
|
372 | + * @param array $users |
|
373 | + * @return array |
|
374 | + * @suppress SqlInjectionChecker |
|
375 | + */ |
|
376 | + public function getUsedSpaceForUsers(array $users) { |
|
377 | + $builder = $this->connection->getQueryBuilder(); |
|
378 | + |
|
379 | + $slash = $builder->createNamedParameter('/'); |
|
380 | + |
|
381 | + $mountPoint = $builder->func()->concat( |
|
382 | + $builder->func()->concat($slash, 'user_id'), |
|
383 | + $slash |
|
384 | + ); |
|
385 | + |
|
386 | + $userIds = array_map(function (IUser $user) { |
|
387 | + return $user->getUID(); |
|
388 | + }, $users); |
|
389 | + |
|
390 | + $query = $builder->select('m.user_id', 'f.size') |
|
391 | + ->from('mounts', 'm') |
|
392 | + ->innerJoin('m', 'filecache', 'f', |
|
393 | + $builder->expr()->andX( |
|
394 | + $builder->expr()->eq('m.storage_id', 'f.storage'), |
|
395 | + $builder->expr()->eq('f.path_hash', $builder->createNamedParameter(md5('files'))) |
|
396 | + )) |
|
397 | + ->where($builder->expr()->eq('m.mount_point', $mountPoint)) |
|
398 | + ->andWhere($builder->expr()->in('m.user_id', $builder->createNamedParameter($userIds, IQueryBuilder::PARAM_STR_ARRAY))); |
|
399 | + |
|
400 | + $result = $query->execute(); |
|
401 | + |
|
402 | + $results = []; |
|
403 | + while ($row = $result->fetch()) { |
|
404 | + $results[$row['user_id']] = $row['size']; |
|
405 | + } |
|
406 | + $result->closeCursor(); |
|
407 | + return $results; |
|
408 | + } |
|
409 | 409 | } |
@@ -28,62 +28,62 @@ |
||
28 | 28 | |
29 | 29 | class Logger implements ILogger { |
30 | 30 | |
31 | - /** @var ILogger */ |
|
32 | - private $logger; |
|
31 | + /** @var ILogger */ |
|
32 | + private $logger; |
|
33 | 33 | |
34 | - /** @var string */ |
|
35 | - private $appName; |
|
34 | + /** @var string */ |
|
35 | + private $appName; |
|
36 | 36 | |
37 | - public function __construct(ILogger $logger, string $appName) { |
|
38 | - $this->logger = $logger; |
|
39 | - $this->appName = $appName; |
|
40 | - } |
|
37 | + public function __construct(ILogger $logger, string $appName) { |
|
38 | + $this->logger = $logger; |
|
39 | + $this->appName = $appName; |
|
40 | + } |
|
41 | 41 | |
42 | - private function extendContext(array $context): array { |
|
43 | - if (!isset($context['app'])) { |
|
44 | - $context['app'] = $this->appName; |
|
45 | - } |
|
42 | + private function extendContext(array $context): array { |
|
43 | + if (!isset($context['app'])) { |
|
44 | + $context['app'] = $this->appName; |
|
45 | + } |
|
46 | 46 | |
47 | - return $context; |
|
48 | - } |
|
47 | + return $context; |
|
48 | + } |
|
49 | 49 | |
50 | - public function emergency(string $message, array $context = []) { |
|
51 | - $this->logger->emergency($message, $this->extendContext($context)); |
|
52 | - } |
|
50 | + public function emergency(string $message, array $context = []) { |
|
51 | + $this->logger->emergency($message, $this->extendContext($context)); |
|
52 | + } |
|
53 | 53 | |
54 | - public function alert(string $message, array $context = []) { |
|
55 | - $this->logger->alert($message, $this->extendContext($context)); |
|
56 | - } |
|
54 | + public function alert(string $message, array $context = []) { |
|
55 | + $this->logger->alert($message, $this->extendContext($context)); |
|
56 | + } |
|
57 | 57 | |
58 | - public function critical(string $message, array $context = []) { |
|
59 | - $this->logger->critical($message, $this->extendContext($context)); |
|
60 | - } |
|
58 | + public function critical(string $message, array $context = []) { |
|
59 | + $this->logger->critical($message, $this->extendContext($context)); |
|
60 | + } |
|
61 | 61 | |
62 | - public function error(string $message, array $context = []) { |
|
63 | - $this->logger->emergency($message, $this->extendContext($context)); |
|
64 | - } |
|
62 | + public function error(string $message, array $context = []) { |
|
63 | + $this->logger->emergency($message, $this->extendContext($context)); |
|
64 | + } |
|
65 | 65 | |
66 | - public function warning(string $message, array $context = []) { |
|
67 | - $this->logger->warning($message, $this->extendContext($context)); |
|
68 | - } |
|
66 | + public function warning(string $message, array $context = []) { |
|
67 | + $this->logger->warning($message, $this->extendContext($context)); |
|
68 | + } |
|
69 | 69 | |
70 | - public function notice(string $message, array $context = []) { |
|
71 | - $this->logger->notice($message, $this->extendContext($context)); |
|
72 | - } |
|
70 | + public function notice(string $message, array $context = []) { |
|
71 | + $this->logger->notice($message, $this->extendContext($context)); |
|
72 | + } |
|
73 | 73 | |
74 | - public function info(string $message, array $context = []) { |
|
75 | - $this->logger->info($message, $this->extendContext($context)); |
|
76 | - } |
|
74 | + public function info(string $message, array $context = []) { |
|
75 | + $this->logger->info($message, $this->extendContext($context)); |
|
76 | + } |
|
77 | 77 | |
78 | - public function debug(string $message, array $context = []) { |
|
79 | - $this->logger->debug($message, $this->extendContext($context)); |
|
80 | - } |
|
78 | + public function debug(string $message, array $context = []) { |
|
79 | + $this->logger->debug($message, $this->extendContext($context)); |
|
80 | + } |
|
81 | 81 | |
82 | - public function log(int $level, string $message, array $context = []) { |
|
83 | - $this->logger->log($level, $message, $this->extendContext($context)); |
|
84 | - } |
|
82 | + public function log(int $level, string $message, array $context = []) { |
|
83 | + $this->logger->log($level, $message, $this->extendContext($context)); |
|
84 | + } |
|
85 | 85 | |
86 | - public function logException(\Throwable $exception, array $context = []) { |
|
87 | - $this->logger->logException($exception, $this->extendContext($context)); |
|
88 | - } |
|
86 | + public function logException(\Throwable $exception, array $context = []) { |
|
87 | + $this->logger->logException($exception, $this->extendContext($context)); |
|
88 | + } |
|
89 | 89 | } |