@@ -32,10 +32,10 @@ |
||
32 | 32 | */ |
33 | 33 | interface IShareHelper { |
34 | 34 | |
35 | - /** |
|
36 | - * @param Node $node |
|
37 | - * @return array [ users => [Mapping $uid => $pathForUser], remotes => [Mapping $cloudId => $pathToMountRoot]] |
|
38 | - * @since 12 |
|
39 | - */ |
|
40 | - public function getPathsForAccessList(Node $node); |
|
35 | + /** |
|
36 | + * @param Node $node |
|
37 | + * @return array [ users => [Mapping $uid => $pathForUser], remotes => [Mapping $cloudId => $pathToMountRoot]] |
|
38 | + * @since 12 |
|
39 | + */ |
|
40 | + public function getPathsForAccessList(Node $node); |
|
41 | 41 | } |
@@ -31,187 +31,187 @@ |
||
31 | 31 | |
32 | 32 | class ShareHelper implements IShareHelper { |
33 | 33 | |
34 | - /** @var IManager */ |
|
35 | - private $shareManager; |
|
36 | - |
|
37 | - public function __construct(IManager $shareManager) { |
|
38 | - $this->shareManager = $shareManager; |
|
39 | - } |
|
40 | - |
|
41 | - /** |
|
42 | - * @param Node $node |
|
43 | - * @return array [ users => [Mapping $uid => $pathForUser], remotes => [Mapping $cloudId => $pathToMountRoot]] |
|
44 | - */ |
|
45 | - public function getPathsForAccessList(Node $node) { |
|
46 | - $result = [ |
|
47 | - 'users' => [], |
|
48 | - 'remotes' => [], |
|
49 | - ]; |
|
50 | - |
|
51 | - $accessList = $this->shareManager->getAccessList($node, true, true); |
|
52 | - if (!empty($accessList['users'])) { |
|
53 | - $result['users'] = $this->getPathsForUsers($node, $accessList['users']); |
|
54 | - } |
|
55 | - if (!empty($accessList['remote'])) { |
|
56 | - $result['remotes'] = $this->getPathsForRemotes($node, $accessList['remote']); |
|
57 | - } |
|
58 | - |
|
59 | - return $result; |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * Sample: |
|
64 | - * $users = [ |
|
65 | - * 'test1' => ['node_id' => 16, 'node_path' => '/foo'], |
|
66 | - * 'test2' => ['node_id' => 23, 'node_path' => '/bar'], |
|
67 | - * 'test3' => ['node_id' => 42, 'node_path' => '/cat'], |
|
68 | - * 'test4' => ['node_id' => 48, 'node_path' => '/dog'], |
|
69 | - * ]; |
|
70 | - * |
|
71 | - * Node tree: |
|
72 | - * - SixTeen is the parent of TwentyThree |
|
73 | - * - TwentyThree is the parent of FortyTwo |
|
74 | - * - FortyEight does not exist |
|
75 | - * |
|
76 | - * $return = [ |
|
77 | - * 'test1' => '/foo/TwentyThree/FortyTwo', |
|
78 | - * 'test2' => '/bar/FortyTwo', |
|
79 | - * 'test3' => '/cat', |
|
80 | - * ], |
|
81 | - * |
|
82 | - * @param Node $node |
|
83 | - * @param array[] $users |
|
84 | - * @return array |
|
85 | - */ |
|
86 | - protected function getPathsForUsers(Node $node, array $users) { |
|
87 | - /** @var array[] $byId */ |
|
88 | - $byId = []; |
|
89 | - /** @var array[] $results */ |
|
90 | - $results = []; |
|
91 | - |
|
92 | - foreach ($users as $uid => $info) { |
|
93 | - if (!isset($byId[$info['node_id']])) { |
|
94 | - $byId[$info['node_id']] = []; |
|
95 | - } |
|
96 | - $byId[$info['node_id']][$uid] = $info['node_path']; |
|
97 | - } |
|
98 | - |
|
99 | - try { |
|
100 | - if (isset($byId[$node->getId()])) { |
|
101 | - foreach ($byId[$node->getId()] as $uid => $path) { |
|
102 | - $results[$uid] = $path; |
|
103 | - } |
|
104 | - unset($byId[$node->getId()]); |
|
105 | - } |
|
106 | - } catch (NotFoundException $e) { |
|
107 | - return $results; |
|
108 | - } catch (InvalidPathException $e) { |
|
109 | - return $results; |
|
110 | - } |
|
111 | - |
|
112 | - if (empty($byId)) { |
|
113 | - return $results; |
|
114 | - } |
|
115 | - |
|
116 | - $item = $node; |
|
117 | - $appendix = '/' . $node->getName(); |
|
118 | - while (!empty($byId)) { |
|
119 | - try { |
|
120 | - /** @var Node $item */ |
|
121 | - $item = $item->getParent(); |
|
122 | - |
|
123 | - if (!empty($byId[$item->getId()])) { |
|
124 | - foreach ($byId[$item->getId()] as $uid => $path) { |
|
125 | - $results[$uid] = $path . $appendix; |
|
126 | - } |
|
127 | - unset($byId[$item->getId()]); |
|
128 | - } |
|
129 | - |
|
130 | - $appendix = '/' . $item->getName() . $appendix; |
|
131 | - } catch (NotFoundException $e) { |
|
132 | - return $results; |
|
133 | - } catch (InvalidPathException $e) { |
|
134 | - return $results; |
|
135 | - } catch (NotPermittedException $e) { |
|
136 | - return $results; |
|
137 | - } |
|
138 | - } |
|
139 | - |
|
140 | - return $results; |
|
141 | - } |
|
142 | - |
|
143 | - /** |
|
144 | - * Sample: |
|
145 | - * $remotes = [ |
|
146 | - * 'test1' => ['node_id' => 16, 'token' => 't1'], |
|
147 | - * 'test2' => ['node_id' => 23, 'token' => 't2'], |
|
148 | - * 'test3' => ['node_id' => 42, 'token' => 't3'], |
|
149 | - * 'test4' => ['node_id' => 48, 'token' => 't4'], |
|
150 | - * ]; |
|
151 | - * |
|
152 | - * Node tree: |
|
153 | - * - SixTeen is the parent of TwentyThree |
|
154 | - * - TwentyThree is the parent of FortyTwo |
|
155 | - * - FortyEight does not exist |
|
156 | - * |
|
157 | - * $return = [ |
|
158 | - * 'test1' => ['token' => 't1', 'node_path' => '/SixTeen'], |
|
159 | - * 'test2' => ['token' => 't2', 'node_path' => '/SixTeen/TwentyThree'], |
|
160 | - * 'test3' => ['token' => 't3', 'node_path' => '/SixTeen/TwentyThree/FortyTwo'], |
|
161 | - * ], |
|
162 | - * |
|
163 | - * @param Node $node |
|
164 | - * @param array[] $remotes |
|
165 | - * @return array |
|
166 | - */ |
|
167 | - protected function getPathsForRemotes(Node $node, array $remotes) { |
|
168 | - /** @var array[] $byId */ |
|
169 | - $byId = []; |
|
170 | - /** @var array[] $results */ |
|
171 | - $results = []; |
|
172 | - |
|
173 | - foreach ($remotes as $cloudId => $info) { |
|
174 | - if (!isset($byId[$info['node_id']])) { |
|
175 | - $byId[$info['node_id']] = []; |
|
176 | - } |
|
177 | - $byId[$info['node_id']][$cloudId] = $info['token']; |
|
178 | - } |
|
179 | - |
|
180 | - $item = $node; |
|
181 | - while (!empty($byId)) { |
|
182 | - try { |
|
183 | - if (!empty($byId[$item->getId()])) { |
|
184 | - $path = $this->getMountedPath($item); |
|
185 | - foreach ($byId[$item->getId()] as $uid => $token) { |
|
186 | - $results[$uid] = [ |
|
187 | - 'node_path' => $path, |
|
188 | - 'token' => $token, |
|
189 | - ]; |
|
190 | - } |
|
191 | - unset($byId[$item->getId()]); |
|
192 | - } |
|
193 | - |
|
194 | - /** @var Node $item */ |
|
195 | - $item = $item->getParent(); |
|
196 | - } catch (NotFoundException $e) { |
|
197 | - return $results; |
|
198 | - } catch (InvalidPathException $e) { |
|
199 | - return $results; |
|
200 | - } catch (NotPermittedException $e) { |
|
201 | - return $results; |
|
202 | - } |
|
203 | - } |
|
204 | - |
|
205 | - return $results; |
|
206 | - } |
|
207 | - |
|
208 | - /** |
|
209 | - * @param Node $node |
|
210 | - * @return string |
|
211 | - */ |
|
212 | - protected function getMountedPath(Node $node) { |
|
213 | - $path = $node->getPath(); |
|
214 | - $sections = explode('/', $path, 4); |
|
215 | - return '/' . $sections[3]; |
|
216 | - } |
|
34 | + /** @var IManager */ |
|
35 | + private $shareManager; |
|
36 | + |
|
37 | + public function __construct(IManager $shareManager) { |
|
38 | + $this->shareManager = $shareManager; |
|
39 | + } |
|
40 | + |
|
41 | + /** |
|
42 | + * @param Node $node |
|
43 | + * @return array [ users => [Mapping $uid => $pathForUser], remotes => [Mapping $cloudId => $pathToMountRoot]] |
|
44 | + */ |
|
45 | + public function getPathsForAccessList(Node $node) { |
|
46 | + $result = [ |
|
47 | + 'users' => [], |
|
48 | + 'remotes' => [], |
|
49 | + ]; |
|
50 | + |
|
51 | + $accessList = $this->shareManager->getAccessList($node, true, true); |
|
52 | + if (!empty($accessList['users'])) { |
|
53 | + $result['users'] = $this->getPathsForUsers($node, $accessList['users']); |
|
54 | + } |
|
55 | + if (!empty($accessList['remote'])) { |
|
56 | + $result['remotes'] = $this->getPathsForRemotes($node, $accessList['remote']); |
|
57 | + } |
|
58 | + |
|
59 | + return $result; |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * Sample: |
|
64 | + * $users = [ |
|
65 | + * 'test1' => ['node_id' => 16, 'node_path' => '/foo'], |
|
66 | + * 'test2' => ['node_id' => 23, 'node_path' => '/bar'], |
|
67 | + * 'test3' => ['node_id' => 42, 'node_path' => '/cat'], |
|
68 | + * 'test4' => ['node_id' => 48, 'node_path' => '/dog'], |
|
69 | + * ]; |
|
70 | + * |
|
71 | + * Node tree: |
|
72 | + * - SixTeen is the parent of TwentyThree |
|
73 | + * - TwentyThree is the parent of FortyTwo |
|
74 | + * - FortyEight does not exist |
|
75 | + * |
|
76 | + * $return = [ |
|
77 | + * 'test1' => '/foo/TwentyThree/FortyTwo', |
|
78 | + * 'test2' => '/bar/FortyTwo', |
|
79 | + * 'test3' => '/cat', |
|
80 | + * ], |
|
81 | + * |
|
82 | + * @param Node $node |
|
83 | + * @param array[] $users |
|
84 | + * @return array |
|
85 | + */ |
|
86 | + protected function getPathsForUsers(Node $node, array $users) { |
|
87 | + /** @var array[] $byId */ |
|
88 | + $byId = []; |
|
89 | + /** @var array[] $results */ |
|
90 | + $results = []; |
|
91 | + |
|
92 | + foreach ($users as $uid => $info) { |
|
93 | + if (!isset($byId[$info['node_id']])) { |
|
94 | + $byId[$info['node_id']] = []; |
|
95 | + } |
|
96 | + $byId[$info['node_id']][$uid] = $info['node_path']; |
|
97 | + } |
|
98 | + |
|
99 | + try { |
|
100 | + if (isset($byId[$node->getId()])) { |
|
101 | + foreach ($byId[$node->getId()] as $uid => $path) { |
|
102 | + $results[$uid] = $path; |
|
103 | + } |
|
104 | + unset($byId[$node->getId()]); |
|
105 | + } |
|
106 | + } catch (NotFoundException $e) { |
|
107 | + return $results; |
|
108 | + } catch (InvalidPathException $e) { |
|
109 | + return $results; |
|
110 | + } |
|
111 | + |
|
112 | + if (empty($byId)) { |
|
113 | + return $results; |
|
114 | + } |
|
115 | + |
|
116 | + $item = $node; |
|
117 | + $appendix = '/' . $node->getName(); |
|
118 | + while (!empty($byId)) { |
|
119 | + try { |
|
120 | + /** @var Node $item */ |
|
121 | + $item = $item->getParent(); |
|
122 | + |
|
123 | + if (!empty($byId[$item->getId()])) { |
|
124 | + foreach ($byId[$item->getId()] as $uid => $path) { |
|
125 | + $results[$uid] = $path . $appendix; |
|
126 | + } |
|
127 | + unset($byId[$item->getId()]); |
|
128 | + } |
|
129 | + |
|
130 | + $appendix = '/' . $item->getName() . $appendix; |
|
131 | + } catch (NotFoundException $e) { |
|
132 | + return $results; |
|
133 | + } catch (InvalidPathException $e) { |
|
134 | + return $results; |
|
135 | + } catch (NotPermittedException $e) { |
|
136 | + return $results; |
|
137 | + } |
|
138 | + } |
|
139 | + |
|
140 | + return $results; |
|
141 | + } |
|
142 | + |
|
143 | + /** |
|
144 | + * Sample: |
|
145 | + * $remotes = [ |
|
146 | + * 'test1' => ['node_id' => 16, 'token' => 't1'], |
|
147 | + * 'test2' => ['node_id' => 23, 'token' => 't2'], |
|
148 | + * 'test3' => ['node_id' => 42, 'token' => 't3'], |
|
149 | + * 'test4' => ['node_id' => 48, 'token' => 't4'], |
|
150 | + * ]; |
|
151 | + * |
|
152 | + * Node tree: |
|
153 | + * - SixTeen is the parent of TwentyThree |
|
154 | + * - TwentyThree is the parent of FortyTwo |
|
155 | + * - FortyEight does not exist |
|
156 | + * |
|
157 | + * $return = [ |
|
158 | + * 'test1' => ['token' => 't1', 'node_path' => '/SixTeen'], |
|
159 | + * 'test2' => ['token' => 't2', 'node_path' => '/SixTeen/TwentyThree'], |
|
160 | + * 'test3' => ['token' => 't3', 'node_path' => '/SixTeen/TwentyThree/FortyTwo'], |
|
161 | + * ], |
|
162 | + * |
|
163 | + * @param Node $node |
|
164 | + * @param array[] $remotes |
|
165 | + * @return array |
|
166 | + */ |
|
167 | + protected function getPathsForRemotes(Node $node, array $remotes) { |
|
168 | + /** @var array[] $byId */ |
|
169 | + $byId = []; |
|
170 | + /** @var array[] $results */ |
|
171 | + $results = []; |
|
172 | + |
|
173 | + foreach ($remotes as $cloudId => $info) { |
|
174 | + if (!isset($byId[$info['node_id']])) { |
|
175 | + $byId[$info['node_id']] = []; |
|
176 | + } |
|
177 | + $byId[$info['node_id']][$cloudId] = $info['token']; |
|
178 | + } |
|
179 | + |
|
180 | + $item = $node; |
|
181 | + while (!empty($byId)) { |
|
182 | + try { |
|
183 | + if (!empty($byId[$item->getId()])) { |
|
184 | + $path = $this->getMountedPath($item); |
|
185 | + foreach ($byId[$item->getId()] as $uid => $token) { |
|
186 | + $results[$uid] = [ |
|
187 | + 'node_path' => $path, |
|
188 | + 'token' => $token, |
|
189 | + ]; |
|
190 | + } |
|
191 | + unset($byId[$item->getId()]); |
|
192 | + } |
|
193 | + |
|
194 | + /** @var Node $item */ |
|
195 | + $item = $item->getParent(); |
|
196 | + } catch (NotFoundException $e) { |
|
197 | + return $results; |
|
198 | + } catch (InvalidPathException $e) { |
|
199 | + return $results; |
|
200 | + } catch (NotPermittedException $e) { |
|
201 | + return $results; |
|
202 | + } |
|
203 | + } |
|
204 | + |
|
205 | + return $results; |
|
206 | + } |
|
207 | + |
|
208 | + /** |
|
209 | + * @param Node $node |
|
210 | + * @return string |
|
211 | + */ |
|
212 | + protected function getMountedPath(Node $node) { |
|
213 | + $path = $node->getPath(); |
|
214 | + $sections = explode('/', $path, 4); |
|
215 | + return '/' . $sections[3]; |
|
216 | + } |
|
217 | 217 | } |
@@ -28,13 +28,13 @@ |
||
28 | 28 | * @brief wraps around static Nextcloud core methods |
29 | 29 | */ |
30 | 30 | class LogWrapper { |
31 | - protected $app = 'user_ldap'; |
|
31 | + protected $app = 'user_ldap'; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @brief states whether the filesystem was loaded |
|
35 | - * @return bool |
|
36 | - */ |
|
37 | - public function log($msg, $level) { |
|
38 | - \OCP\Util::writeLog($this->app, $msg, $level); |
|
39 | - } |
|
33 | + /** |
|
34 | + * @brief states whether the filesystem was loaded |
|
35 | + * @return bool |
|
36 | + */ |
|
37 | + public function log($msg, $level) { |
|
38 | + \OCP\Util::writeLog($this->app, $msg, $level); |
|
39 | + } |
|
40 | 40 | } |
@@ -29,19 +29,19 @@ |
||
29 | 29 | */ |
30 | 30 | class FilesystemHelper { |
31 | 31 | |
32 | - /** |
|
33 | - * @brief states whether the filesystem was loaded |
|
34 | - * @return bool |
|
35 | - */ |
|
36 | - public function isLoaded() { |
|
37 | - return \OC\Files\Filesystem::$loaded; |
|
38 | - } |
|
32 | + /** |
|
33 | + * @brief states whether the filesystem was loaded |
|
34 | + * @return bool |
|
35 | + */ |
|
36 | + public function isLoaded() { |
|
37 | + return \OC\Files\Filesystem::$loaded; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @brief initializes the filesystem for the given user |
|
42 | - * @param string $uid the Nextcloud username of the user |
|
43 | - */ |
|
44 | - public function setup($uid) { |
|
45 | - \OC_Util::setupFS($uid); |
|
46 | - } |
|
40 | + /** |
|
41 | + * @brief initializes the filesystem for the given user |
|
42 | + * @param string $uid the Nextcloud username of the user |
|
43 | + */ |
|
44 | + public function setup($uid) { |
|
45 | + \OC_Util::setupFS($uid); |
|
46 | + } |
|
47 | 47 | } |
@@ -42,97 +42,97 @@ |
||
42 | 42 | * Migrate mount config from mount.json to the database |
43 | 43 | */ |
44 | 44 | class StorageMigrator { |
45 | - /** |
|
46 | - * @var BackendService |
|
47 | - */ |
|
48 | - private $backendService; |
|
45 | + /** |
|
46 | + * @var BackendService |
|
47 | + */ |
|
48 | + private $backendService; |
|
49 | 49 | |
50 | - /** |
|
51 | - * @var DBConfigService |
|
52 | - */ |
|
53 | - private $dbConfig; |
|
50 | + /** |
|
51 | + * @var DBConfigService |
|
52 | + */ |
|
53 | + private $dbConfig; |
|
54 | 54 | |
55 | - /** |
|
56 | - * @var IConfig |
|
57 | - */ |
|
58 | - private $config; |
|
55 | + /** |
|
56 | + * @var IConfig |
|
57 | + */ |
|
58 | + private $config; |
|
59 | 59 | |
60 | - /** |
|
61 | - * @var IDBConnection |
|
62 | - */ |
|
63 | - private $connection; |
|
60 | + /** |
|
61 | + * @var IDBConnection |
|
62 | + */ |
|
63 | + private $connection; |
|
64 | 64 | |
65 | - /** |
|
66 | - * @var ILogger |
|
67 | - */ |
|
68 | - private $logger; |
|
65 | + /** |
|
66 | + * @var ILogger |
|
67 | + */ |
|
68 | + private $logger; |
|
69 | 69 | |
70 | - /** @var IUserMountCache */ |
|
71 | - private $userMountCache; |
|
70 | + /** @var IUserMountCache */ |
|
71 | + private $userMountCache; |
|
72 | 72 | |
73 | - /** |
|
74 | - * StorageMigrator constructor. |
|
75 | - * |
|
76 | - * @param BackendService $backendService |
|
77 | - * @param DBConfigService $dbConfig |
|
78 | - * @param IConfig $config |
|
79 | - * @param IDBConnection $connection |
|
80 | - * @param ILogger $logger |
|
81 | - * @param IUserMountCache $userMountCache |
|
82 | - */ |
|
83 | - public function __construct( |
|
84 | - BackendService $backendService, |
|
85 | - DBConfigService $dbConfig, |
|
86 | - IConfig $config, |
|
87 | - IDBConnection $connection, |
|
88 | - ILogger $logger, |
|
89 | - IUserMountCache $userMountCache |
|
90 | - ) { |
|
91 | - $this->backendService = $backendService; |
|
92 | - $this->dbConfig = $dbConfig; |
|
93 | - $this->config = $config; |
|
94 | - $this->connection = $connection; |
|
95 | - $this->logger = $logger; |
|
96 | - $this->userMountCache = $userMountCache; |
|
97 | - } |
|
73 | + /** |
|
74 | + * StorageMigrator constructor. |
|
75 | + * |
|
76 | + * @param BackendService $backendService |
|
77 | + * @param DBConfigService $dbConfig |
|
78 | + * @param IConfig $config |
|
79 | + * @param IDBConnection $connection |
|
80 | + * @param ILogger $logger |
|
81 | + * @param IUserMountCache $userMountCache |
|
82 | + */ |
|
83 | + public function __construct( |
|
84 | + BackendService $backendService, |
|
85 | + DBConfigService $dbConfig, |
|
86 | + IConfig $config, |
|
87 | + IDBConnection $connection, |
|
88 | + ILogger $logger, |
|
89 | + IUserMountCache $userMountCache |
|
90 | + ) { |
|
91 | + $this->backendService = $backendService; |
|
92 | + $this->dbConfig = $dbConfig; |
|
93 | + $this->config = $config; |
|
94 | + $this->connection = $connection; |
|
95 | + $this->logger = $logger; |
|
96 | + $this->userMountCache = $userMountCache; |
|
97 | + } |
|
98 | 98 | |
99 | - private function migrate(LegacyStoragesService $legacyService, StoragesService $storageService) { |
|
100 | - $existingStorage = $legacyService->getAllStorages(); |
|
99 | + private function migrate(LegacyStoragesService $legacyService, StoragesService $storageService) { |
|
100 | + $existingStorage = $legacyService->getAllStorages(); |
|
101 | 101 | |
102 | - $this->connection->beginTransaction(); |
|
103 | - try { |
|
104 | - foreach ($existingStorage as $storage) { |
|
105 | - $mountOptions = $storage->getMountOptions(); |
|
106 | - if (!empty($mountOptions) && !isset($mountOptions['enable_sharing'])) { |
|
107 | - // existing mounts must have sharing enabled by default to avoid surprises |
|
108 | - $mountOptions['enable_sharing'] = true; |
|
109 | - $storage->setMountOptions($mountOptions); |
|
110 | - } |
|
111 | - $storageService->addStorage($storage); |
|
112 | - } |
|
113 | - $this->connection->commit(); |
|
114 | - } catch (\Exception $e) { |
|
115 | - $this->logger->logException($e); |
|
116 | - $this->connection->rollBack(); |
|
117 | - } |
|
118 | - } |
|
102 | + $this->connection->beginTransaction(); |
|
103 | + try { |
|
104 | + foreach ($existingStorage as $storage) { |
|
105 | + $mountOptions = $storage->getMountOptions(); |
|
106 | + if (!empty($mountOptions) && !isset($mountOptions['enable_sharing'])) { |
|
107 | + // existing mounts must have sharing enabled by default to avoid surprises |
|
108 | + $mountOptions['enable_sharing'] = true; |
|
109 | + $storage->setMountOptions($mountOptions); |
|
110 | + } |
|
111 | + $storageService->addStorage($storage); |
|
112 | + } |
|
113 | + $this->connection->commit(); |
|
114 | + } catch (\Exception $e) { |
|
115 | + $this->logger->logException($e); |
|
116 | + $this->connection->rollBack(); |
|
117 | + } |
|
118 | + } |
|
119 | 119 | |
120 | - /** |
|
121 | - * Migrate personal storages configured by the current user |
|
122 | - * |
|
123 | - * @param IUser $user |
|
124 | - */ |
|
125 | - public function migrateUser(IUser $user) { |
|
126 | - $dummySession = new DummyUserSession(); |
|
127 | - $dummySession->setUser($user); |
|
128 | - $userId = $user->getUID(); |
|
129 | - $userVersion = $this->config->getUserValue($userId, 'files_external', 'config_version', '0.0.0'); |
|
130 | - if (version_compare($userVersion, '0.5.0', '<')) { |
|
131 | - $this->config->setUserValue($userId, 'files_external', 'config_version', '0.5.0'); |
|
132 | - $legacyService = new UserLegacyStoragesService($this->backendService, $dummySession); |
|
133 | - $storageService = new UserStoragesService($this->backendService, $this->dbConfig, $dummySession, $this->userMountCache); |
|
120 | + /** |
|
121 | + * Migrate personal storages configured by the current user |
|
122 | + * |
|
123 | + * @param IUser $user |
|
124 | + */ |
|
125 | + public function migrateUser(IUser $user) { |
|
126 | + $dummySession = new DummyUserSession(); |
|
127 | + $dummySession->setUser($user); |
|
128 | + $userId = $user->getUID(); |
|
129 | + $userVersion = $this->config->getUserValue($userId, 'files_external', 'config_version', '0.0.0'); |
|
130 | + if (version_compare($userVersion, '0.5.0', '<')) { |
|
131 | + $this->config->setUserValue($userId, 'files_external', 'config_version', '0.5.0'); |
|
132 | + $legacyService = new UserLegacyStoragesService($this->backendService, $dummySession); |
|
133 | + $storageService = new UserStoragesService($this->backendService, $this->dbConfig, $dummySession, $this->userMountCache); |
|
134 | 134 | |
135 | - $this->migrate($legacyService, $storageService); |
|
136 | - } |
|
137 | - } |
|
135 | + $this->migrate($legacyService, $storageService); |
|
136 | + } |
|
137 | + } |
|
138 | 138 | } |
@@ -25,28 +25,28 @@ |
||
25 | 25 | use OCP\AppFramework\Http\JSONResponse; |
26 | 26 | |
27 | 27 | class RateLimitTestController extends Controller { |
28 | - /** |
|
29 | - * @PublicPage |
|
30 | - * @NoCSRFRequired |
|
31 | - * |
|
32 | - * @UserRateThrottle(limit=5, period=100) |
|
33 | - * @AnonRateThrottle(limit=1, period=100) |
|
34 | - * |
|
35 | - * @return JSONResponse |
|
36 | - */ |
|
37 | - public function userAndAnonProtected() { |
|
38 | - return new JSONResponse(); |
|
39 | - } |
|
28 | + /** |
|
29 | + * @PublicPage |
|
30 | + * @NoCSRFRequired |
|
31 | + * |
|
32 | + * @UserRateThrottle(limit=5, period=100) |
|
33 | + * @AnonRateThrottle(limit=1, period=100) |
|
34 | + * |
|
35 | + * @return JSONResponse |
|
36 | + */ |
|
37 | + public function userAndAnonProtected() { |
|
38 | + return new JSONResponse(); |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * @PublicPage |
|
43 | - * @NoCSRFRequired |
|
44 | - * |
|
45 | - * @AnonRateThrottle(limit=1, period=10) |
|
46 | - * |
|
47 | - * @return JSONResponse |
|
48 | - */ |
|
49 | - public function onlyAnonProtected() { |
|
50 | - return new JSONResponse(); |
|
51 | - } |
|
41 | + /** |
|
42 | + * @PublicPage |
|
43 | + * @NoCSRFRequired |
|
44 | + * |
|
45 | + * @AnonRateThrottle(limit=1, period=10) |
|
46 | + * |
|
47 | + * @return JSONResponse |
|
48 | + */ |
|
49 | + public function onlyAnonProtected() { |
|
50 | + return new JSONResponse(); |
|
51 | + } |
|
52 | 52 | } |
@@ -25,7 +25,7 @@ |
||
25 | 25 | use OCP\AppFramework\Http; |
26 | 26 | |
27 | 27 | class RateLimitExceededException extends SecurityException { |
28 | - public function __construct() { |
|
29 | - parent::__construct('Rate limit exceeded', Http::STATUS_TOO_MANY_REQUESTS); |
|
30 | - } |
|
28 | + public function __construct() { |
|
29 | + parent::__construct('Rate limit exceeded', Http::STATUS_TOO_MANY_REQUESTS); |
|
30 | + } |
|
31 | 31 | } |
@@ -23,20 +23,20 @@ |
||
23 | 23 | |
24 | 24 | class CoreBundle extends Bundle { |
25 | 25 | |
26 | - /** |
|
27 | - * {@inheritDoc} |
|
28 | - */ |
|
29 | - public function getName() { |
|
30 | - return 'Core bundle'; |
|
31 | - } |
|
26 | + /** |
|
27 | + * {@inheritDoc} |
|
28 | + */ |
|
29 | + public function getName() { |
|
30 | + return 'Core bundle'; |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * {@inheritDoc} |
|
35 | - */ |
|
36 | - public function getAppIdentifiers() { |
|
37 | - return [ |
|
38 | - 'bruteforcesettings', |
|
39 | - ]; |
|
40 | - } |
|
33 | + /** |
|
34 | + * {@inheritDoc} |
|
35 | + */ |
|
36 | + public function getAppIdentifiers() { |
|
37 | + return [ |
|
38 | + 'bruteforcesettings', |
|
39 | + ]; |
|
40 | + } |
|
41 | 41 | |
42 | 42 | } |
@@ -35,55 +35,55 @@ |
||
35 | 35 | * @since 8.0.0 |
36 | 36 | */ |
37 | 37 | interface IEventLogger { |
38 | - /** |
|
39 | - * Mark the start of an event setting its ID $id and providing event description $description. |
|
40 | - * |
|
41 | - * @param string $id |
|
42 | - * @param string $description |
|
43 | - * @since 8.0.0 |
|
44 | - */ |
|
45 | - public function start($id, $description); |
|
38 | + /** |
|
39 | + * Mark the start of an event setting its ID $id and providing event description $description. |
|
40 | + * |
|
41 | + * @param string $id |
|
42 | + * @param string $description |
|
43 | + * @since 8.0.0 |
|
44 | + */ |
|
45 | + public function start($id, $description); |
|
46 | 46 | |
47 | - /** |
|
48 | - * Mark the end of an event with specific ID $id, marked by start() method. |
|
49 | - * Ending event should store \OCP\Diagnostics\IEvent to |
|
50 | - * be returned with getEvents() method. |
|
51 | - * |
|
52 | - * @param string $id |
|
53 | - * @since 8.0.0 |
|
54 | - */ |
|
55 | - public function end($id); |
|
47 | + /** |
|
48 | + * Mark the end of an event with specific ID $id, marked by start() method. |
|
49 | + * Ending event should store \OCP\Diagnostics\IEvent to |
|
50 | + * be returned with getEvents() method. |
|
51 | + * |
|
52 | + * @param string $id |
|
53 | + * @since 8.0.0 |
|
54 | + */ |
|
55 | + public function end($id); |
|
56 | 56 | |
57 | - /** |
|
58 | - * Mark the start and the end of an event with specific ID $id and description $description, |
|
59 | - * explicitly marking start and end of the event, represented by $start and $end timestamps. |
|
60 | - * Logging event should store \OCP\Diagnostics\IEvent to |
|
61 | - * be returned with getEvents() method. |
|
62 | - * |
|
63 | - * @param string $id |
|
64 | - * @param string $description |
|
65 | - * @param float $start |
|
66 | - * @param float $end |
|
67 | - * @since 8.0.0 |
|
68 | - */ |
|
69 | - public function log($id, $description, $start, $end); |
|
57 | + /** |
|
58 | + * Mark the start and the end of an event with specific ID $id and description $description, |
|
59 | + * explicitly marking start and end of the event, represented by $start and $end timestamps. |
|
60 | + * Logging event should store \OCP\Diagnostics\IEvent to |
|
61 | + * be returned with getEvents() method. |
|
62 | + * |
|
63 | + * @param string $id |
|
64 | + * @param string $description |
|
65 | + * @param float $start |
|
66 | + * @param float $end |
|
67 | + * @since 8.0.0 |
|
68 | + */ |
|
69 | + public function log($id, $description, $start, $end); |
|
70 | 70 | |
71 | - /** |
|
72 | - * This method should return all \OCP\Diagnostics\IEvent objects stored using |
|
73 | - * start()/end() or log() methods |
|
74 | - * |
|
75 | - * @return \OCP\Diagnostics\IEvent[] |
|
76 | - * @since 8.0.0 |
|
77 | - */ |
|
78 | - public function getEvents(); |
|
71 | + /** |
|
72 | + * This method should return all \OCP\Diagnostics\IEvent objects stored using |
|
73 | + * start()/end() or log() methods |
|
74 | + * |
|
75 | + * @return \OCP\Diagnostics\IEvent[] |
|
76 | + * @since 8.0.0 |
|
77 | + */ |
|
78 | + public function getEvents(); |
|
79 | 79 | |
80 | - /** |
|
81 | - * Activate the module for the duration of the request. Deactivated module |
|
82 | - * does not create and store \OCP\Diagnostics\IEvent objects. |
|
83 | - * Only activated module should create and store objects to be |
|
84 | - * returned with getEvents() call. |
|
85 | - * |
|
86 | - * @since 12.0.0 |
|
87 | - */ |
|
88 | - public function activate(); |
|
80 | + /** |
|
81 | + * Activate the module for the duration of the request. Deactivated module |
|
82 | + * does not create and store \OCP\Diagnostics\IEvent objects. |
|
83 | + * Only activated module should create and store objects to be |
|
84 | + * returned with getEvents() call. |
|
85 | + * |
|
86 | + * @since 12.0.0 |
|
87 | + */ |
|
88 | + public function activate(); |
|
89 | 89 | } |