@@ -42,127 +42,127 @@ |
||
42 | 42 | * @since 24.0.0 |
43 | 43 | */ |
44 | 44 | interface IProfile { |
45 | - /** |
|
46 | - * Get the token of the profile |
|
47 | - * @since 24.0.0 |
|
48 | - */ |
|
49 | - public function getToken(): string; |
|
50 | - |
|
51 | - /** |
|
52 | - * Set the token of the profile |
|
53 | - * @since 24.0.0 |
|
54 | - */ |
|
55 | - public function setToken(string $token): void; |
|
56 | - |
|
57 | - /** |
|
58 | - * Get the time of the profile |
|
59 | - * @since 24.0.0 |
|
60 | - */ |
|
61 | - public function getTime(): ?int; |
|
62 | - |
|
63 | - /** |
|
64 | - * Set the time of the profile |
|
65 | - * @since 24.0.0 |
|
66 | - */ |
|
67 | - public function setTime(int $time): void; |
|
68 | - |
|
69 | - /** |
|
70 | - * Get the url of the profile |
|
71 | - * @since 24.0.0 |
|
72 | - */ |
|
73 | - public function getUrl(): ?string; |
|
74 | - |
|
75 | - /** |
|
76 | - * Set the url of the profile |
|
77 | - * @since 24.0.0 |
|
78 | - */ |
|
79 | - public function setUrl(string $url): void; |
|
80 | - |
|
81 | - /** |
|
82 | - * Get the method of the profile |
|
83 | - * @since 24.0.0 |
|
84 | - */ |
|
85 | - public function getMethod(): ?string; |
|
86 | - |
|
87 | - /** |
|
88 | - * Set the method of the profile |
|
89 | - * @since 24.0.0 |
|
90 | - */ |
|
91 | - public function setMethod(string $method): void; |
|
92 | - |
|
93 | - /** |
|
94 | - * Get the status code of the profile |
|
95 | - * @since 24.0.0 |
|
96 | - */ |
|
97 | - public function getStatusCode(): ?int; |
|
98 | - |
|
99 | - /** |
|
100 | - * Set the status code of the profile |
|
101 | - * @since 24.0.0 |
|
102 | - */ |
|
103 | - public function setStatusCode(int $statusCode): void; |
|
104 | - |
|
105 | - /** |
|
106 | - * Add a data collector to the profile |
|
107 | - * @since 24.0.0 |
|
108 | - */ |
|
109 | - public function addCollector(IDataCollector $collector); |
|
110 | - |
|
111 | - /** |
|
112 | - * Get the parent profile to this profile |
|
113 | - * @since 24.0.0 |
|
114 | - */ |
|
115 | - public function getParent(): ?IProfile; |
|
116 | - |
|
117 | - /** |
|
118 | - * Set the parent profile to this profile |
|
119 | - * @since 24.0.0 |
|
120 | - */ |
|
121 | - public function setParent(?IProfile $parent): void; |
|
122 | - |
|
123 | - /** |
|
124 | - * Get the parent token to this profile |
|
125 | - * @since 24.0.0 |
|
126 | - */ |
|
127 | - public function getParentToken(): ?string; |
|
128 | - |
|
129 | - /** |
|
130 | - * Get the profile's children |
|
131 | - * @return IProfile[] |
|
132 | - * @since 24.0.0 |
|
133 | - **/ |
|
134 | - public function getChildren(): array; |
|
135 | - |
|
136 | - /** |
|
137 | - * Set the profile's children |
|
138 | - * @param IProfile[] $children |
|
139 | - * @since 24.0.0 |
|
140 | - */ |
|
141 | - public function setChildren(array $children): void; |
|
142 | - |
|
143 | - /** |
|
144 | - * Add the child profile |
|
145 | - * @since 24.0.0 |
|
146 | - */ |
|
147 | - public function addChild(IProfile $profile): void; |
|
148 | - |
|
149 | - /** |
|
150 | - * Get all the data collectors |
|
151 | - * @return IDataCollector[] |
|
152 | - * @since 24.0.0 |
|
153 | - */ |
|
154 | - public function getCollectors(): array; |
|
155 | - |
|
156 | - /** |
|
157 | - * Set all the data collectors |
|
158 | - * @param IDataCollector[] $collectors |
|
159 | - * @since 24.0.0 |
|
160 | - */ |
|
161 | - public function setCollectors(array $collectors): void; |
|
162 | - |
|
163 | - /** |
|
164 | - * Get a data collector by name |
|
165 | - * @since 24.0.0 |
|
166 | - */ |
|
167 | - public function getCollector(string $collectorName): ?IDataCollector; |
|
45 | + /** |
|
46 | + * Get the token of the profile |
|
47 | + * @since 24.0.0 |
|
48 | + */ |
|
49 | + public function getToken(): string; |
|
50 | + |
|
51 | + /** |
|
52 | + * Set the token of the profile |
|
53 | + * @since 24.0.0 |
|
54 | + */ |
|
55 | + public function setToken(string $token): void; |
|
56 | + |
|
57 | + /** |
|
58 | + * Get the time of the profile |
|
59 | + * @since 24.0.0 |
|
60 | + */ |
|
61 | + public function getTime(): ?int; |
|
62 | + |
|
63 | + /** |
|
64 | + * Set the time of the profile |
|
65 | + * @since 24.0.0 |
|
66 | + */ |
|
67 | + public function setTime(int $time): void; |
|
68 | + |
|
69 | + /** |
|
70 | + * Get the url of the profile |
|
71 | + * @since 24.0.0 |
|
72 | + */ |
|
73 | + public function getUrl(): ?string; |
|
74 | + |
|
75 | + /** |
|
76 | + * Set the url of the profile |
|
77 | + * @since 24.0.0 |
|
78 | + */ |
|
79 | + public function setUrl(string $url): void; |
|
80 | + |
|
81 | + /** |
|
82 | + * Get the method of the profile |
|
83 | + * @since 24.0.0 |
|
84 | + */ |
|
85 | + public function getMethod(): ?string; |
|
86 | + |
|
87 | + /** |
|
88 | + * Set the method of the profile |
|
89 | + * @since 24.0.0 |
|
90 | + */ |
|
91 | + public function setMethod(string $method): void; |
|
92 | + |
|
93 | + /** |
|
94 | + * Get the status code of the profile |
|
95 | + * @since 24.0.0 |
|
96 | + */ |
|
97 | + public function getStatusCode(): ?int; |
|
98 | + |
|
99 | + /** |
|
100 | + * Set the status code of the profile |
|
101 | + * @since 24.0.0 |
|
102 | + */ |
|
103 | + public function setStatusCode(int $statusCode): void; |
|
104 | + |
|
105 | + /** |
|
106 | + * Add a data collector to the profile |
|
107 | + * @since 24.0.0 |
|
108 | + */ |
|
109 | + public function addCollector(IDataCollector $collector); |
|
110 | + |
|
111 | + /** |
|
112 | + * Get the parent profile to this profile |
|
113 | + * @since 24.0.0 |
|
114 | + */ |
|
115 | + public function getParent(): ?IProfile; |
|
116 | + |
|
117 | + /** |
|
118 | + * Set the parent profile to this profile |
|
119 | + * @since 24.0.0 |
|
120 | + */ |
|
121 | + public function setParent(?IProfile $parent): void; |
|
122 | + |
|
123 | + /** |
|
124 | + * Get the parent token to this profile |
|
125 | + * @since 24.0.0 |
|
126 | + */ |
|
127 | + public function getParentToken(): ?string; |
|
128 | + |
|
129 | + /** |
|
130 | + * Get the profile's children |
|
131 | + * @return IProfile[] |
|
132 | + * @since 24.0.0 |
|
133 | + **/ |
|
134 | + public function getChildren(): array; |
|
135 | + |
|
136 | + /** |
|
137 | + * Set the profile's children |
|
138 | + * @param IProfile[] $children |
|
139 | + * @since 24.0.0 |
|
140 | + */ |
|
141 | + public function setChildren(array $children): void; |
|
142 | + |
|
143 | + /** |
|
144 | + * Add the child profile |
|
145 | + * @since 24.0.0 |
|
146 | + */ |
|
147 | + public function addChild(IProfile $profile): void; |
|
148 | + |
|
149 | + /** |
|
150 | + * Get all the data collectors |
|
151 | + * @return IDataCollector[] |
|
152 | + * @since 24.0.0 |
|
153 | + */ |
|
154 | + public function getCollectors(): array; |
|
155 | + |
|
156 | + /** |
|
157 | + * Set all the data collectors |
|
158 | + * @param IDataCollector[] $collectors |
|
159 | + * @since 24.0.0 |
|
160 | + */ |
|
161 | + public function setCollectors(array $collectors): void; |
|
162 | + |
|
163 | + /** |
|
164 | + * Get a data collector by name |
|
165 | + * @since 24.0.0 |
|
166 | + */ |
|
167 | + public function getCollector(string $collectorName): ?IDataCollector; |
|
168 | 168 | } |
@@ -35,37 +35,37 @@ |
||
35 | 35 | namespace OC\DB; |
36 | 36 | |
37 | 37 | final class ObjectParameter { |
38 | - private $object; |
|
39 | - private $error; |
|
40 | - private $stringable; |
|
41 | - private $class; |
|
38 | + private $object; |
|
39 | + private $error; |
|
40 | + private $stringable; |
|
41 | + private $class; |
|
42 | 42 | |
43 | - /** |
|
44 | - * @param object $object |
|
45 | - */ |
|
46 | - public function __construct($object, ?\Throwable $error) { |
|
47 | - $this->object = $object; |
|
48 | - $this->error = $error; |
|
49 | - $this->stringable = \is_callable([$object, '__toString']); |
|
50 | - $this->class = \get_class($object); |
|
51 | - } |
|
43 | + /** |
|
44 | + * @param object $object |
|
45 | + */ |
|
46 | + public function __construct($object, ?\Throwable $error) { |
|
47 | + $this->object = $object; |
|
48 | + $this->error = $error; |
|
49 | + $this->stringable = \is_callable([$object, '__toString']); |
|
50 | + $this->class = \get_class($object); |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @return object |
|
55 | - */ |
|
56 | - public function getObject() { |
|
57 | - return $this->object; |
|
58 | - } |
|
53 | + /** |
|
54 | + * @return object |
|
55 | + */ |
|
56 | + public function getObject() { |
|
57 | + return $this->object; |
|
58 | + } |
|
59 | 59 | |
60 | - public function getError(): ?\Throwable { |
|
61 | - return $this->error; |
|
62 | - } |
|
60 | + public function getError(): ?\Throwable { |
|
61 | + return $this->error; |
|
62 | + } |
|
63 | 63 | |
64 | - public function isStringable(): bool { |
|
65 | - return $this->stringable; |
|
66 | - } |
|
64 | + public function isStringable(): bool { |
|
65 | + return $this->stringable; |
|
66 | + } |
|
67 | 67 | |
68 | - public function getClass(): string { |
|
69 | - return $this->class; |
|
70 | - } |
|
68 | + public function getClass(): string { |
|
69 | + return $this->class; |
|
70 | + } |
|
71 | 71 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | /** |
5 | 5 | * This file is part of the Symfony package. |
6 | 6 | * |
@@ -29,140 +29,140 @@ |
||
29 | 29 | use OCP\Profiler\IProfile; |
30 | 30 | |
31 | 31 | class Profile implements \JsonSerializable, IProfile { |
32 | - private string $token; |
|
32 | + private string $token; |
|
33 | 33 | |
34 | - private ?int $time = null; |
|
34 | + private ?int $time = null; |
|
35 | 35 | |
36 | - private ?string $url = null; |
|
36 | + private ?string $url = null; |
|
37 | 37 | |
38 | - private ?string $method = null; |
|
38 | + private ?string $method = null; |
|
39 | 39 | |
40 | - private ?int $statusCode = null; |
|
40 | + private ?int $statusCode = null; |
|
41 | 41 | |
42 | - /** @var array<string, IDataCollector> */ |
|
43 | - private array $collectors = []; |
|
42 | + /** @var array<string, IDataCollector> */ |
|
43 | + private array $collectors = []; |
|
44 | 44 | |
45 | - private ?IProfile $parent = null; |
|
45 | + private ?IProfile $parent = null; |
|
46 | 46 | |
47 | - /** @var IProfile[] */ |
|
48 | - private array $children = []; |
|
47 | + /** @var IProfile[] */ |
|
48 | + private array $children = []; |
|
49 | 49 | |
50 | - public function __construct(string $token) { |
|
51 | - $this->token = $token; |
|
52 | - } |
|
53 | - |
|
54 | - public function getToken(): string { |
|
55 | - return $this->token; |
|
56 | - } |
|
57 | - |
|
58 | - public function setToken(string $token): void { |
|
59 | - $this->token = $token; |
|
60 | - } |
|
61 | - |
|
62 | - public function getTime(): ?int { |
|
63 | - return $this->time; |
|
64 | - } |
|
65 | - |
|
66 | - public function setTime(int $time): void { |
|
67 | - $this->time = $time; |
|
68 | - } |
|
69 | - |
|
70 | - public function getUrl(): ?string { |
|
71 | - return $this->url; |
|
72 | - } |
|
73 | - |
|
74 | - public function setUrl(string $url): void { |
|
75 | - $this->url = $url; |
|
76 | - } |
|
77 | - |
|
78 | - public function getMethod(): ?string { |
|
79 | - return $this->method; |
|
80 | - } |
|
81 | - |
|
82 | - public function setMethod(string $method): void { |
|
83 | - $this->method = $method; |
|
84 | - } |
|
85 | - |
|
86 | - public function getStatusCode(): ?int { |
|
87 | - return $this->statusCode; |
|
88 | - } |
|
89 | - |
|
90 | - public function setStatusCode(int $statusCode): void { |
|
91 | - $this->statusCode = $statusCode; |
|
92 | - } |
|
93 | - |
|
94 | - public function addCollector(IDataCollector $collector) { |
|
95 | - $this->collectors[$collector->getName()] = $collector; |
|
96 | - } |
|
97 | - |
|
98 | - public function getParent(): ?IProfile { |
|
99 | - return $this->parent; |
|
100 | - } |
|
101 | - |
|
102 | - public function setParent(?IProfile $parent): void { |
|
103 | - $this->parent = $parent; |
|
104 | - } |
|
105 | - |
|
106 | - public function getParentToken(): ?string { |
|
107 | - return $this->parent ? $this->parent->getToken() : null; |
|
108 | - } |
|
109 | - |
|
110 | - /** @return IProfile[] */ |
|
111 | - public function getChildren(): array { |
|
112 | - return $this->children; |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * @param IProfile[] $children |
|
117 | - */ |
|
118 | - public function setChildren(array $children): void { |
|
119 | - $this->children = []; |
|
120 | - foreach ($children as $child) { |
|
121 | - $this->addChild($child); |
|
122 | - } |
|
123 | - } |
|
124 | - |
|
125 | - public function addChild(IProfile $profile): void { |
|
126 | - $this->children[] = $profile; |
|
127 | - $profile->setParent($this); |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * @return IDataCollector[] |
|
132 | - */ |
|
133 | - public function getCollectors(): array { |
|
134 | - return $this->collectors; |
|
135 | - } |
|
136 | - |
|
137 | - /** |
|
138 | - * @param IDataCollector[] $collectors |
|
139 | - */ |
|
140 | - public function setCollectors(array $collectors): void { |
|
141 | - $this->collectors = $collectors; |
|
142 | - } |
|
143 | - |
|
144 | - public function __sleep(): array { |
|
145 | - return ['token', 'parent', 'children', 'collectors', 'method', 'url', 'time', 'statusCode']; |
|
146 | - } |
|
147 | - |
|
148 | - #[\ReturnTypeWillChange] |
|
149 | - public function jsonSerialize() { |
|
150 | - // Everything but parent |
|
151 | - return [ |
|
152 | - 'token' => $this->token, |
|
153 | - 'method' => $this->method, |
|
154 | - 'children' => $this->children, |
|
155 | - 'url' => $this->url, |
|
156 | - 'statusCode' => $this->statusCode, |
|
157 | - 'time' => $this->time, |
|
158 | - 'collectors' => $this->collectors, |
|
159 | - ]; |
|
160 | - } |
|
161 | - |
|
162 | - public function getCollector(string $collectorName): ?IDataCollector { |
|
163 | - if (!array_key_exists($collectorName, $this->collectors)) { |
|
164 | - return null; |
|
165 | - } |
|
166 | - return $this->collectors[$collectorName]; |
|
167 | - } |
|
50 | + public function __construct(string $token) { |
|
51 | + $this->token = $token; |
|
52 | + } |
|
53 | + |
|
54 | + public function getToken(): string { |
|
55 | + return $this->token; |
|
56 | + } |
|
57 | + |
|
58 | + public function setToken(string $token): void { |
|
59 | + $this->token = $token; |
|
60 | + } |
|
61 | + |
|
62 | + public function getTime(): ?int { |
|
63 | + return $this->time; |
|
64 | + } |
|
65 | + |
|
66 | + public function setTime(int $time): void { |
|
67 | + $this->time = $time; |
|
68 | + } |
|
69 | + |
|
70 | + public function getUrl(): ?string { |
|
71 | + return $this->url; |
|
72 | + } |
|
73 | + |
|
74 | + public function setUrl(string $url): void { |
|
75 | + $this->url = $url; |
|
76 | + } |
|
77 | + |
|
78 | + public function getMethod(): ?string { |
|
79 | + return $this->method; |
|
80 | + } |
|
81 | + |
|
82 | + public function setMethod(string $method): void { |
|
83 | + $this->method = $method; |
|
84 | + } |
|
85 | + |
|
86 | + public function getStatusCode(): ?int { |
|
87 | + return $this->statusCode; |
|
88 | + } |
|
89 | + |
|
90 | + public function setStatusCode(int $statusCode): void { |
|
91 | + $this->statusCode = $statusCode; |
|
92 | + } |
|
93 | + |
|
94 | + public function addCollector(IDataCollector $collector) { |
|
95 | + $this->collectors[$collector->getName()] = $collector; |
|
96 | + } |
|
97 | + |
|
98 | + public function getParent(): ?IProfile { |
|
99 | + return $this->parent; |
|
100 | + } |
|
101 | + |
|
102 | + public function setParent(?IProfile $parent): void { |
|
103 | + $this->parent = $parent; |
|
104 | + } |
|
105 | + |
|
106 | + public function getParentToken(): ?string { |
|
107 | + return $this->parent ? $this->parent->getToken() : null; |
|
108 | + } |
|
109 | + |
|
110 | + /** @return IProfile[] */ |
|
111 | + public function getChildren(): array { |
|
112 | + return $this->children; |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * @param IProfile[] $children |
|
117 | + */ |
|
118 | + public function setChildren(array $children): void { |
|
119 | + $this->children = []; |
|
120 | + foreach ($children as $child) { |
|
121 | + $this->addChild($child); |
|
122 | + } |
|
123 | + } |
|
124 | + |
|
125 | + public function addChild(IProfile $profile): void { |
|
126 | + $this->children[] = $profile; |
|
127 | + $profile->setParent($this); |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * @return IDataCollector[] |
|
132 | + */ |
|
133 | + public function getCollectors(): array { |
|
134 | + return $this->collectors; |
|
135 | + } |
|
136 | + |
|
137 | + /** |
|
138 | + * @param IDataCollector[] $collectors |
|
139 | + */ |
|
140 | + public function setCollectors(array $collectors): void { |
|
141 | + $this->collectors = $collectors; |
|
142 | + } |
|
143 | + |
|
144 | + public function __sleep(): array { |
|
145 | + return ['token', 'parent', 'children', 'collectors', 'method', 'url', 'time', 'statusCode']; |
|
146 | + } |
|
147 | + |
|
148 | + #[\ReturnTypeWillChange] |
|
149 | + public function jsonSerialize() { |
|
150 | + // Everything but parent |
|
151 | + return [ |
|
152 | + 'token' => $this->token, |
|
153 | + 'method' => $this->method, |
|
154 | + 'children' => $this->children, |
|
155 | + 'url' => $this->url, |
|
156 | + 'statusCode' => $this->statusCode, |
|
157 | + 'time' => $this->time, |
|
158 | + 'collectors' => $this->collectors, |
|
159 | + ]; |
|
160 | + } |
|
161 | + |
|
162 | + public function getCollector(string $collectorName): ?IDataCollector { |
|
163 | + if (!array_key_exists($collectorName, $this->collectors)) { |
|
164 | + return null; |
|
165 | + } |
|
166 | + return $this->collectors[$collectorName]; |
|
167 | + } |
|
168 | 168 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types = 1); |
|
3 | +declare(strict_types=1); |
|
4 | 4 | /** |
5 | 5 | * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors |
6 | 6 | * SPDX-License-Identifier: AGPL-3.0-or-later |
@@ -83,7 +83,7 @@ |
||
83 | 83 | |
84 | 84 | if ($row) { |
85 | 85 | $this->cache[$storageId] = $row; |
86 | - $this->numericIdCache[(int)$row['numeric_id']] = $row; |
|
86 | + $this->numericIdCache[(int) $row['numeric_id']] = $row; |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | return $this->cache[$storageId] ?? null; |
@@ -21,79 +21,79 @@ |
||
21 | 21 | * @package OC\Files\Cache |
22 | 22 | */ |
23 | 23 | class StorageGlobal { |
24 | - /** @var array<string, array> */ |
|
25 | - private $cache = []; |
|
26 | - /** @var array<int, array> */ |
|
27 | - private $numericIdCache = []; |
|
24 | + /** @var array<string, array> */ |
|
25 | + private $cache = []; |
|
26 | + /** @var array<int, array> */ |
|
27 | + private $numericIdCache = []; |
|
28 | 28 | |
29 | - public function __construct( |
|
30 | - private IDBConnection $connection, |
|
31 | - ) { |
|
32 | - } |
|
29 | + public function __construct( |
|
30 | + private IDBConnection $connection, |
|
31 | + ) { |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * @param string[] $storageIds |
|
36 | - */ |
|
37 | - public function loadForStorageIds(array $storageIds) { |
|
38 | - $builder = $this->connection->getQueryBuilder(); |
|
39 | - $query = $builder->select(['id', 'numeric_id', 'available', 'last_checked']) |
|
40 | - ->from('storages') |
|
41 | - ->where($builder->expr()->in('id', $builder->createNamedParameter(array_values($storageIds), IQueryBuilder::PARAM_STR_ARRAY))); |
|
34 | + /** |
|
35 | + * @param string[] $storageIds |
|
36 | + */ |
|
37 | + public function loadForStorageIds(array $storageIds) { |
|
38 | + $builder = $this->connection->getQueryBuilder(); |
|
39 | + $query = $builder->select(['id', 'numeric_id', 'available', 'last_checked']) |
|
40 | + ->from('storages') |
|
41 | + ->where($builder->expr()->in('id', $builder->createNamedParameter(array_values($storageIds), IQueryBuilder::PARAM_STR_ARRAY))); |
|
42 | 42 | |
43 | - $result = $query->executeQuery(); |
|
44 | - while ($row = $result->fetch()) { |
|
45 | - $this->cache[$row['id']] = $row; |
|
46 | - } |
|
47 | - $result->closeCursor(); |
|
48 | - } |
|
43 | + $result = $query->executeQuery(); |
|
44 | + while ($row = $result->fetch()) { |
|
45 | + $this->cache[$row['id']] = $row; |
|
46 | + } |
|
47 | + $result->closeCursor(); |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @param string $storageId |
|
52 | - * @return array|null |
|
53 | - */ |
|
54 | - public function getStorageInfo(string $storageId): ?array { |
|
55 | - if (!isset($this->cache[$storageId])) { |
|
56 | - $builder = $this->connection->getQueryBuilder(); |
|
57 | - $query = $builder->select(['id', 'numeric_id', 'available', 'last_checked']) |
|
58 | - ->from('storages') |
|
59 | - ->where($builder->expr()->eq('id', $builder->createNamedParameter($storageId))); |
|
50 | + /** |
|
51 | + * @param string $storageId |
|
52 | + * @return array|null |
|
53 | + */ |
|
54 | + public function getStorageInfo(string $storageId): ?array { |
|
55 | + if (!isset($this->cache[$storageId])) { |
|
56 | + $builder = $this->connection->getQueryBuilder(); |
|
57 | + $query = $builder->select(['id', 'numeric_id', 'available', 'last_checked']) |
|
58 | + ->from('storages') |
|
59 | + ->where($builder->expr()->eq('id', $builder->createNamedParameter($storageId))); |
|
60 | 60 | |
61 | - $result = $query->executeQuery(); |
|
62 | - $row = $result->fetch(); |
|
63 | - $result->closeCursor(); |
|
61 | + $result = $query->executeQuery(); |
|
62 | + $row = $result->fetch(); |
|
63 | + $result->closeCursor(); |
|
64 | 64 | |
65 | - if ($row) { |
|
66 | - $this->cache[$storageId] = $row; |
|
67 | - $this->numericIdCache[(int)$row['numeric_id']] = $row; |
|
68 | - } |
|
69 | - } |
|
70 | - return $this->cache[$storageId] ?? null; |
|
71 | - } |
|
65 | + if ($row) { |
|
66 | + $this->cache[$storageId] = $row; |
|
67 | + $this->numericIdCache[(int)$row['numeric_id']] = $row; |
|
68 | + } |
|
69 | + } |
|
70 | + return $this->cache[$storageId] ?? null; |
|
71 | + } |
|
72 | 72 | |
73 | - /** |
|
74 | - * @param int $numericId |
|
75 | - * @return array|null |
|
76 | - */ |
|
77 | - public function getStorageInfoByNumericId(int $numericId): ?array { |
|
78 | - if (!isset($this->numericIdCache[$numericId])) { |
|
79 | - $builder = $this->connection->getQueryBuilder(); |
|
80 | - $query = $builder->select(['id', 'numeric_id', 'available', 'last_checked']) |
|
81 | - ->from('storages') |
|
82 | - ->where($builder->expr()->eq('numeric_id', $builder->createNamedParameter($numericId))); |
|
73 | + /** |
|
74 | + * @param int $numericId |
|
75 | + * @return array|null |
|
76 | + */ |
|
77 | + public function getStorageInfoByNumericId(int $numericId): ?array { |
|
78 | + if (!isset($this->numericIdCache[$numericId])) { |
|
79 | + $builder = $this->connection->getQueryBuilder(); |
|
80 | + $query = $builder->select(['id', 'numeric_id', 'available', 'last_checked']) |
|
81 | + ->from('storages') |
|
82 | + ->where($builder->expr()->eq('numeric_id', $builder->createNamedParameter($numericId))); |
|
83 | 83 | |
84 | - $result = $query->executeQuery(); |
|
85 | - $row = $result->fetch(); |
|
86 | - $result->closeCursor(); |
|
84 | + $result = $query->executeQuery(); |
|
85 | + $row = $result->fetch(); |
|
86 | + $result->closeCursor(); |
|
87 | 87 | |
88 | - if ($row) { |
|
89 | - $this->numericIdCache[$numericId] = $row; |
|
90 | - $this->cache[$row['id']] = $row; |
|
91 | - } |
|
92 | - } |
|
93 | - return $this->numericIdCache[$numericId] ?? null; |
|
94 | - } |
|
88 | + if ($row) { |
|
89 | + $this->numericIdCache[$numericId] = $row; |
|
90 | + $this->cache[$row['id']] = $row; |
|
91 | + } |
|
92 | + } |
|
93 | + return $this->numericIdCache[$numericId] ?? null; |
|
94 | + } |
|
95 | 95 | |
96 | - public function clearCache() { |
|
97 | - $this->cache = []; |
|
98 | - } |
|
96 | + public function clearCache() { |
|
97 | + $this->cache = []; |
|
98 | + } |
|
99 | 99 | } |
@@ -65,12 +65,12 @@ |
||
65 | 65 | $node = $this->server->tree->getNodeForPath($path); |
66 | 66 | if ($node instanceof File) { |
67 | 67 | $type = strtolower( |
68 | - (string)$request->getHeader('X-Recalculate-Hash') |
|
68 | + (string) $request->getHeader('X-Recalculate-Hash') |
|
69 | 69 | ); |
70 | 70 | |
71 | 71 | $hash = $node->hash($type); |
72 | 72 | if ($hash) { |
73 | - $checksum = strtoupper($type) . ':' . $hash; |
|
73 | + $checksum = strtoupper($type).':'.$hash; |
|
74 | 74 | $node->setChecksum($checksum); |
75 | 75 | $response->addHeader('OC-Checksum', $checksum); |
76 | 76 | $response->setHeader('Content-Length', '0'); |
@@ -15,41 +15,41 @@ |
||
15 | 15 | use Sabre\HTTP\ResponseInterface; |
16 | 16 | |
17 | 17 | class ChecksumUpdatePlugin extends ServerPlugin { |
18 | - protected ?Server $server = null; |
|
19 | - |
|
20 | - public function initialize(Server $server) { |
|
21 | - $this->server = $server; |
|
22 | - $server->on('method:PATCH', [$this, 'httpPatch']); |
|
23 | - } |
|
24 | - |
|
25 | - public function getPluginName(): string { |
|
26 | - return 'checksumupdate'; |
|
27 | - } |
|
28 | - |
|
29 | - /** @return string[] */ |
|
30 | - public function getFeatures(): array { |
|
31 | - return ['nextcloud-checksum-update']; |
|
32 | - } |
|
33 | - |
|
34 | - public function httpPatch(RequestInterface $request, ResponseInterface $response) { |
|
35 | - $path = $request->getPath(); |
|
36 | - |
|
37 | - $node = $this->server->tree->getNodeForPath($path); |
|
38 | - if ($node instanceof File) { |
|
39 | - $type = strtolower( |
|
40 | - (string)$request->getHeader('X-Recalculate-Hash') |
|
41 | - ); |
|
42 | - |
|
43 | - $hash = $node->hash($type); |
|
44 | - if ($hash) { |
|
45 | - $checksum = strtoupper($type) . ':' . $hash; |
|
46 | - $node->setChecksum($checksum); |
|
47 | - $response->addHeader('OC-Checksum', $checksum); |
|
48 | - $response->setHeader('Content-Length', '0'); |
|
49 | - $response->setStatus(Http::STATUS_NO_CONTENT); |
|
50 | - |
|
51 | - return false; |
|
52 | - } |
|
53 | - } |
|
54 | - } |
|
18 | + protected ?Server $server = null; |
|
19 | + |
|
20 | + public function initialize(Server $server) { |
|
21 | + $this->server = $server; |
|
22 | + $server->on('method:PATCH', [$this, 'httpPatch']); |
|
23 | + } |
|
24 | + |
|
25 | + public function getPluginName(): string { |
|
26 | + return 'checksumupdate'; |
|
27 | + } |
|
28 | + |
|
29 | + /** @return string[] */ |
|
30 | + public function getFeatures(): array { |
|
31 | + return ['nextcloud-checksum-update']; |
|
32 | + } |
|
33 | + |
|
34 | + public function httpPatch(RequestInterface $request, ResponseInterface $response) { |
|
35 | + $path = $request->getPath(); |
|
36 | + |
|
37 | + $node = $this->server->tree->getNodeForPath($path); |
|
38 | + if ($node instanceof File) { |
|
39 | + $type = strtolower( |
|
40 | + (string)$request->getHeader('X-Recalculate-Hash') |
|
41 | + ); |
|
42 | + |
|
43 | + $hash = $node->hash($type); |
|
44 | + if ($hash) { |
|
45 | + $checksum = strtoupper($type) . ':' . $hash; |
|
46 | + $node->setChecksum($checksum); |
|
47 | + $response->addHeader('OC-Checksum', $checksum); |
|
48 | + $response->setHeader('Content-Length', '0'); |
|
49 | + $response->setStatus(Http::STATUS_NO_CONTENT); |
|
50 | + |
|
51 | + return false; |
|
52 | + } |
|
53 | + } |
|
54 | + } |
|
55 | 55 | } |
@@ -58,18 +58,18 @@ |
||
58 | 58 | protected function execute(InputInterface $input, OutputInterface $output): int { |
59 | 59 | $gid = $input->getArgument('groupid'); |
60 | 60 | if ($gid === 'admin') { |
61 | - $output->writeln('<error>Group "' . $gid . '" could not be deleted.</error>'); |
|
61 | + $output->writeln('<error>Group "'.$gid.'" could not be deleted.</error>'); |
|
62 | 62 | return 1; |
63 | 63 | } |
64 | 64 | if (!$this->groupManager->groupExists($gid)) { |
65 | - $output->writeln('<error>Group "' . $gid . '" does not exist.</error>'); |
|
65 | + $output->writeln('<error>Group "'.$gid.'" does not exist.</error>'); |
|
66 | 66 | return 1; |
67 | 67 | } |
68 | 68 | $group = $this->groupManager->get($gid); |
69 | 69 | if ($group->delete()) { |
70 | - $output->writeln('Group "' . $gid . '" was removed'); |
|
70 | + $output->writeln('Group "'.$gid.'" was removed'); |
|
71 | 71 | } else { |
72 | - $output->writeln('<error>Group "' . $gid . '" could not be deleted. Please check the logs.</error>'); |
|
72 | + $output->writeln('<error>Group "'.$gid.'" could not be deleted. Please check the logs.</error>'); |
|
73 | 73 | return 1; |
74 | 74 | } |
75 | 75 | return 0; |
@@ -35,52 +35,52 @@ |
||
35 | 35 | use Symfony\Component\Console\Output\OutputInterface; |
36 | 36 | |
37 | 37 | class Delete extends Base { |
38 | - public function __construct( |
|
39 | - protected IGroupManager $groupManager, |
|
40 | - ) { |
|
41 | - parent::__construct(); |
|
42 | - } |
|
38 | + public function __construct( |
|
39 | + protected IGroupManager $groupManager, |
|
40 | + ) { |
|
41 | + parent::__construct(); |
|
42 | + } |
|
43 | 43 | |
44 | - protected function configure() { |
|
45 | - $this |
|
46 | - ->setName('group:delete') |
|
47 | - ->setDescription('Remove a group') |
|
48 | - ->addArgument( |
|
49 | - 'groupid', |
|
50 | - InputArgument::REQUIRED, |
|
51 | - 'Group name' |
|
52 | - ); |
|
53 | - } |
|
44 | + protected function configure() { |
|
45 | + $this |
|
46 | + ->setName('group:delete') |
|
47 | + ->setDescription('Remove a group') |
|
48 | + ->addArgument( |
|
49 | + 'groupid', |
|
50 | + InputArgument::REQUIRED, |
|
51 | + 'Group name' |
|
52 | + ); |
|
53 | + } |
|
54 | 54 | |
55 | - protected function execute(InputInterface $input, OutputInterface $output): int { |
|
56 | - $gid = $input->getArgument('groupid'); |
|
57 | - if ($gid === 'admin') { |
|
58 | - $output->writeln('<error>Group "' . $gid . '" could not be deleted.</error>'); |
|
59 | - return 1; |
|
60 | - } |
|
61 | - if (!$this->groupManager->groupExists($gid)) { |
|
62 | - $output->writeln('<error>Group "' . $gid . '" does not exist.</error>'); |
|
63 | - return 1; |
|
64 | - } |
|
65 | - $group = $this->groupManager->get($gid); |
|
66 | - if ($group->delete()) { |
|
67 | - $output->writeln('Group "' . $gid . '" was removed'); |
|
68 | - } else { |
|
69 | - $output->writeln('<error>Group "' . $gid . '" could not be deleted. Please check the logs.</error>'); |
|
70 | - return 1; |
|
71 | - } |
|
72 | - return 0; |
|
73 | - } |
|
55 | + protected function execute(InputInterface $input, OutputInterface $output): int { |
|
56 | + $gid = $input->getArgument('groupid'); |
|
57 | + if ($gid === 'admin') { |
|
58 | + $output->writeln('<error>Group "' . $gid . '" could not be deleted.</error>'); |
|
59 | + return 1; |
|
60 | + } |
|
61 | + if (!$this->groupManager->groupExists($gid)) { |
|
62 | + $output->writeln('<error>Group "' . $gid . '" does not exist.</error>'); |
|
63 | + return 1; |
|
64 | + } |
|
65 | + $group = $this->groupManager->get($gid); |
|
66 | + if ($group->delete()) { |
|
67 | + $output->writeln('Group "' . $gid . '" was removed'); |
|
68 | + } else { |
|
69 | + $output->writeln('<error>Group "' . $gid . '" could not be deleted. Please check the logs.</error>'); |
|
70 | + return 1; |
|
71 | + } |
|
72 | + return 0; |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * @param string $argumentName |
|
77 | - * @param CompletionContext $context |
|
78 | - * @return string[] |
|
79 | - */ |
|
80 | - public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
81 | - if ($argumentName === 'groupid') { |
|
82 | - return array_map(static fn (IGroup $group) => $group->getGID(), $this->groupManager->search($context->getCurrentWord())); |
|
83 | - } |
|
84 | - return []; |
|
85 | - } |
|
75 | + /** |
|
76 | + * @param string $argumentName |
|
77 | + * @param CompletionContext $context |
|
78 | + * @return string[] |
|
79 | + */ |
|
80 | + public function completeArgumentValues($argumentName, CompletionContext $context) { |
|
81 | + if ($argumentName === 'groupid') { |
|
82 | + return array_map(static fn (IGroup $group) => $group->getGID(), $this->groupManager->search($context->getCurrentWord())); |
|
83 | + } |
|
84 | + return []; |
|
85 | + } |
|
86 | 86 | } |
@@ -35,22 +35,22 @@ |
||
35 | 35 | * Auto-generated migration step: Please modify to your needs! |
36 | 36 | */ |
37 | 37 | class Version24000Date20220404142216 extends SimpleMigrationStep { |
38 | - /** |
|
39 | - * @param IOutput $output |
|
40 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
41 | - * @param array $options |
|
42 | - * @return null|ISchemaWrapper |
|
43 | - */ |
|
44 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
45 | - /** @var ISchemaWrapper $schema */ |
|
46 | - $schema = $schemaClosure(); |
|
38 | + /** |
|
39 | + * @param IOutput $output |
|
40 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
41 | + * @param array $options |
|
42 | + * @return null|ISchemaWrapper |
|
43 | + */ |
|
44 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
45 | + /** @var ISchemaWrapper $schema */ |
|
46 | + $schema = $schemaClosure(); |
|
47 | 47 | |
48 | - $table = $schema->getTable('share_external'); |
|
49 | - $column = $table->getColumn('name'); |
|
50 | - if ($column->getLength() < 4000) { |
|
51 | - $column->setLength(4000); |
|
52 | - return $schema; |
|
53 | - } |
|
54 | - return null; |
|
55 | - } |
|
48 | + $table = $schema->getTable('share_external'); |
|
49 | + $column = $table->getColumn('name'); |
|
50 | + if ($column->getLength() < 4000) { |
|
51 | + $column->setLength(4000); |
|
52 | + return $schema; |
|
53 | + } |
|
54 | + return null; |
|
55 | + } |
|
56 | 56 | } |
@@ -29,71 +29,71 @@ |
||
29 | 29 | * @since 8.0.0 |
30 | 30 | */ |
31 | 31 | interface IMountProviderCollection { |
32 | - /** |
|
33 | - * Get all configured mount points for the user |
|
34 | - * |
|
35 | - * @param \OCP\IUser $user |
|
36 | - * @return \OCP\Files\Mount\IMountPoint[] |
|
37 | - * @since 8.0.0 |
|
38 | - */ |
|
39 | - public function getMountsForUser(IUser $user); |
|
32 | + /** |
|
33 | + * Get all configured mount points for the user |
|
34 | + * |
|
35 | + * @param \OCP\IUser $user |
|
36 | + * @return \OCP\Files\Mount\IMountPoint[] |
|
37 | + * @since 8.0.0 |
|
38 | + */ |
|
39 | + public function getMountsForUser(IUser $user); |
|
40 | 40 | |
41 | - /** |
|
42 | - * Get the configured mount points for the user from a specific mount provider |
|
43 | - * |
|
44 | - * @param \OCP\IUser $user |
|
45 | - * @param class-string<IMountProvider>[] $mountProviderClasses |
|
46 | - * @return \OCP\Files\Mount\IMountPoint[] |
|
47 | - * @since 24.0.0 |
|
48 | - */ |
|
49 | - public function getUserMountsForProviderClasses(IUser $user, array $mountProviderClasses): array; |
|
41 | + /** |
|
42 | + * Get the configured mount points for the user from a specific mount provider |
|
43 | + * |
|
44 | + * @param \OCP\IUser $user |
|
45 | + * @param class-string<IMountProvider>[] $mountProviderClasses |
|
46 | + * @return \OCP\Files\Mount\IMountPoint[] |
|
47 | + * @since 24.0.0 |
|
48 | + */ |
|
49 | + public function getUserMountsForProviderClasses(IUser $user, array $mountProviderClasses): array; |
|
50 | 50 | |
51 | - /** |
|
52 | - * Get the configured home mount for this user |
|
53 | - * |
|
54 | - * @param \OCP\IUser $user |
|
55 | - * @return \OCP\Files\Mount\IMountPoint |
|
56 | - * @since 9.1.0 |
|
57 | - */ |
|
58 | - public function getHomeMountForUser(IUser $user); |
|
51 | + /** |
|
52 | + * Get the configured home mount for this user |
|
53 | + * |
|
54 | + * @param \OCP\IUser $user |
|
55 | + * @return \OCP\Files\Mount\IMountPoint |
|
56 | + * @since 9.1.0 |
|
57 | + */ |
|
58 | + public function getHomeMountForUser(IUser $user); |
|
59 | 59 | |
60 | - /** |
|
61 | - * Add a provider for mount points |
|
62 | - * |
|
63 | - * @param \OCP\Files\Config\IMountProvider $provider |
|
64 | - * @since 8.0.0 |
|
65 | - */ |
|
66 | - public function registerProvider(IMountProvider $provider); |
|
60 | + /** |
|
61 | + * Add a provider for mount points |
|
62 | + * |
|
63 | + * @param \OCP\Files\Config\IMountProvider $provider |
|
64 | + * @since 8.0.0 |
|
65 | + */ |
|
66 | + public function registerProvider(IMountProvider $provider); |
|
67 | 67 | |
68 | - /** |
|
69 | - * Add a filter for mounts |
|
70 | - * |
|
71 | - * @param callable $filter (IMountPoint $mountPoint, IUser $user) => boolean |
|
72 | - * @since 14.0.0 |
|
73 | - */ |
|
74 | - public function registerMountFilter(callable $filter); |
|
68 | + /** |
|
69 | + * Add a filter for mounts |
|
70 | + * |
|
71 | + * @param callable $filter (IMountPoint $mountPoint, IUser $user) => boolean |
|
72 | + * @since 14.0.0 |
|
73 | + */ |
|
74 | + public function registerMountFilter(callable $filter); |
|
75 | 75 | |
76 | - /** |
|
77 | - * Add a provider for home mount points |
|
78 | - * |
|
79 | - * @param \OCP\Files\Config\IHomeMountProvider $provider |
|
80 | - * @since 9.1.0 |
|
81 | - */ |
|
82 | - public function registerHomeProvider(IHomeMountProvider $provider); |
|
76 | + /** |
|
77 | + * Add a provider for home mount points |
|
78 | + * |
|
79 | + * @param \OCP\Files\Config\IHomeMountProvider $provider |
|
80 | + * @since 9.1.0 |
|
81 | + */ |
|
82 | + public function registerHomeProvider(IHomeMountProvider $provider); |
|
83 | 83 | |
84 | - /** |
|
85 | - * Get the mount cache which can be used to search for mounts without setting up the filesystem |
|
86 | - * |
|
87 | - * @return IUserMountCache |
|
88 | - * @since 9.0.0 |
|
89 | - */ |
|
90 | - public function getMountCache(); |
|
84 | + /** |
|
85 | + * Get the mount cache which can be used to search for mounts without setting up the filesystem |
|
86 | + * |
|
87 | + * @return IUserMountCache |
|
88 | + * @since 9.0.0 |
|
89 | + */ |
|
90 | + public function getMountCache(); |
|
91 | 91 | |
92 | - /** |
|
93 | - * Get all root mountpoints |
|
94 | - * |
|
95 | - * @return \OCP\Files\Mount\IMountPoint[] |
|
96 | - * @since 20.0.0 |
|
97 | - */ |
|
98 | - public function getRootMounts(): array; |
|
92 | + /** |
|
93 | + * Get all root mountpoints |
|
94 | + * |
|
95 | + * @return \OCP\Files\Mount\IMountPoint[] |
|
96 | + * @since 20.0.0 |
|
97 | + */ |
|
98 | + public function getRootMounts(): array; |
|
99 | 99 | } |
@@ -32,22 +32,22 @@ |
||
32 | 32 | * @since 24.0.0 |
33 | 33 | */ |
34 | 34 | class OwnerLockedException extends LockedException { |
35 | - private ILock $lock; |
|
35 | + private ILock $lock; |
|
36 | 36 | |
37 | - /** |
|
38 | - * @since 24.0.0 |
|
39 | - */ |
|
40 | - public function __construct(ILock $lock) { |
|
41 | - $this->lock = $lock; |
|
42 | - $path = ''; |
|
43 | - $readablePath = ''; |
|
44 | - parent::__construct($path, null, $lock->getOwner(), $readablePath); |
|
45 | - } |
|
37 | + /** |
|
38 | + * @since 24.0.0 |
|
39 | + */ |
|
40 | + public function __construct(ILock $lock) { |
|
41 | + $this->lock = $lock; |
|
42 | + $path = ''; |
|
43 | + $readablePath = ''; |
|
44 | + parent::__construct($path, null, $lock->getOwner(), $readablePath); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * @since 24.0.0 |
|
49 | - */ |
|
50 | - public function getLock(): ILock { |
|
51 | - return $this->lock; |
|
52 | - } |
|
47 | + /** |
|
48 | + * @since 24.0.0 |
|
49 | + */ |
|
50 | + public function getLock(): ILock { |
|
51 | + return $this->lock; |
|
52 | + } |
|
53 | 53 | } |