@@ -30,18 +30,18 @@ |
||
30 | 30 | * @since 27.0.0 |
31 | 31 | */ |
32 | 32 | interface IParallelAwareJob { |
33 | - /** |
|
34 | - * Set this to false to prevent two Jobs from the same class from running in parallel |
|
35 | - * |
|
36 | - * @param bool $allow |
|
37 | - * @return void |
|
38 | - * @since 27.0.0 |
|
39 | - */ |
|
40 | - public function setAllowParallelRuns(bool $allow): void; |
|
33 | + /** |
|
34 | + * Set this to false to prevent two Jobs from the same class from running in parallel |
|
35 | + * |
|
36 | + * @param bool $allow |
|
37 | + * @return void |
|
38 | + * @since 27.0.0 |
|
39 | + */ |
|
40 | + public function setAllowParallelRuns(bool $allow): void; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @return bool |
|
44 | - * @since 27.0.0 |
|
45 | - */ |
|
46 | - public function getAllowParallelRuns(): bool; |
|
42 | + /** |
|
43 | + * @return bool |
|
44 | + * @since 27.0.0 |
|
45 | + */ |
|
46 | + public function getAllowParallelRuns(): bool; |
|
47 | 47 | } |
@@ -35,73 +35,73 @@ |
||
35 | 35 | * @since 6.0.0 |
36 | 36 | */ |
37 | 37 | interface File extends Node { |
38 | - /** |
|
39 | - * Get the content of the file as string |
|
40 | - * |
|
41 | - * @return string |
|
42 | - * @throws NotPermittedException |
|
43 | - * @throws GenericFileException |
|
44 | - * @throws LockedException |
|
45 | - * @since 6.0.0 |
|
46 | - */ |
|
47 | - public function getContent(); |
|
38 | + /** |
|
39 | + * Get the content of the file as string |
|
40 | + * |
|
41 | + * @return string |
|
42 | + * @throws NotPermittedException |
|
43 | + * @throws GenericFileException |
|
44 | + * @throws LockedException |
|
45 | + * @since 6.0.0 |
|
46 | + */ |
|
47 | + public function getContent(); |
|
48 | 48 | |
49 | - /** |
|
50 | - * Write to the file from string data |
|
51 | - * |
|
52 | - * @param string|resource $data |
|
53 | - * @throws NotPermittedException |
|
54 | - * @throws GenericFileException |
|
55 | - * @throws LockedException |
|
56 | - * @since 6.0.0 |
|
57 | - */ |
|
58 | - public function putContent($data); |
|
49 | + /** |
|
50 | + * Write to the file from string data |
|
51 | + * |
|
52 | + * @param string|resource $data |
|
53 | + * @throws NotPermittedException |
|
54 | + * @throws GenericFileException |
|
55 | + * @throws LockedException |
|
56 | + * @since 6.0.0 |
|
57 | + */ |
|
58 | + public function putContent($data); |
|
59 | 59 | |
60 | - /** |
|
61 | - * Get the mimetype of the file |
|
62 | - * |
|
63 | - * @return string |
|
64 | - * @since 6.0.0 |
|
65 | - */ |
|
66 | - public function getMimeType(); |
|
60 | + /** |
|
61 | + * Get the mimetype of the file |
|
62 | + * |
|
63 | + * @return string |
|
64 | + * @since 6.0.0 |
|
65 | + */ |
|
66 | + public function getMimeType(); |
|
67 | 67 | |
68 | - /** |
|
69 | - * Open the file as stream, resulting resource can be operated as stream like the result from php's own fopen |
|
70 | - * |
|
71 | - * @param string $mode |
|
72 | - * @return resource|false |
|
73 | - * @throws NotPermittedException |
|
74 | - * @throws LockedException |
|
75 | - * @since 6.0.0 |
|
76 | - */ |
|
77 | - public function fopen($mode); |
|
68 | + /** |
|
69 | + * Open the file as stream, resulting resource can be operated as stream like the result from php's own fopen |
|
70 | + * |
|
71 | + * @param string $mode |
|
72 | + * @return resource|false |
|
73 | + * @throws NotPermittedException |
|
74 | + * @throws LockedException |
|
75 | + * @since 6.0.0 |
|
76 | + */ |
|
77 | + public function fopen($mode); |
|
78 | 78 | |
79 | - /** |
|
80 | - * Compute the hash of the file |
|
81 | - * Type of hash is set with $type and can be anything supported by php's hash_file |
|
82 | - * |
|
83 | - * @param string $type |
|
84 | - * @param bool $raw |
|
85 | - * @return string |
|
86 | - * @since 6.0.0 |
|
87 | - */ |
|
88 | - public function hash($type, $raw = false); |
|
79 | + /** |
|
80 | + * Compute the hash of the file |
|
81 | + * Type of hash is set with $type and can be anything supported by php's hash_file |
|
82 | + * |
|
83 | + * @param string $type |
|
84 | + * @param bool $raw |
|
85 | + * @return string |
|
86 | + * @since 6.0.0 |
|
87 | + */ |
|
88 | + public function hash($type, $raw = false); |
|
89 | 89 | |
90 | - /** |
|
91 | - * Get the stored checksum for this file |
|
92 | - * |
|
93 | - * @return string |
|
94 | - * @since 9.0.0 |
|
95 | - * @throws InvalidPathException |
|
96 | - * @throws NotFoundException |
|
97 | - */ |
|
98 | - public function getChecksum(); |
|
90 | + /** |
|
91 | + * Get the stored checksum for this file |
|
92 | + * |
|
93 | + * @return string |
|
94 | + * @since 9.0.0 |
|
95 | + * @throws InvalidPathException |
|
96 | + * @throws NotFoundException |
|
97 | + */ |
|
98 | + public function getChecksum(); |
|
99 | 99 | |
100 | - /** |
|
101 | - * Get the extension of this file |
|
102 | - * |
|
103 | - * @return string |
|
104 | - * @since 15.0.0 |
|
105 | - */ |
|
106 | - public function getExtension(): string; |
|
100 | + /** |
|
101 | + * Get the extension of this file |
|
102 | + * |
|
103 | + * @return string |
|
104 | + * @since 15.0.0 |
|
105 | + */ |
|
106 | + public function getExtension(): string; |
|
107 | 107 | } |
@@ -33,129 +33,129 @@ |
||
33 | 33 | use OCP\Lock\LockedException; |
34 | 34 | |
35 | 35 | class File extends Node implements \OCP\Files\File { |
36 | - /** |
|
37 | - * Creates a Folder that represents a non-existing path |
|
38 | - * |
|
39 | - * @param string $path path |
|
40 | - * @return NonExistingFile non-existing node |
|
41 | - */ |
|
42 | - protected function createNonExistingNode($path) { |
|
43 | - return new NonExistingFile($this->root, $this->view, $path); |
|
44 | - } |
|
36 | + /** |
|
37 | + * Creates a Folder that represents a non-existing path |
|
38 | + * |
|
39 | + * @param string $path path |
|
40 | + * @return NonExistingFile non-existing node |
|
41 | + */ |
|
42 | + protected function createNonExistingNode($path) { |
|
43 | + return new NonExistingFile($this->root, $this->view, $path); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * @return string |
|
48 | - * @throws NotPermittedException |
|
49 | - * @throws GenericFileException |
|
50 | - * @throws LockedException |
|
51 | - */ |
|
52 | - public function getContent() { |
|
53 | - if ($this->checkPermissions(\OCP\Constants::PERMISSION_READ)) { |
|
54 | - $content = $this->view->file_get_contents($this->path); |
|
55 | - if ($content === false) { |
|
56 | - throw new GenericFileException(); |
|
57 | - } |
|
58 | - return $content; |
|
59 | - } else { |
|
60 | - throw new NotPermittedException(); |
|
61 | - } |
|
62 | - } |
|
46 | + /** |
|
47 | + * @return string |
|
48 | + * @throws NotPermittedException |
|
49 | + * @throws GenericFileException |
|
50 | + * @throws LockedException |
|
51 | + */ |
|
52 | + public function getContent() { |
|
53 | + if ($this->checkPermissions(\OCP\Constants::PERMISSION_READ)) { |
|
54 | + $content = $this->view->file_get_contents($this->path); |
|
55 | + if ($content === false) { |
|
56 | + throw new GenericFileException(); |
|
57 | + } |
|
58 | + return $content; |
|
59 | + } else { |
|
60 | + throw new NotPermittedException(); |
|
61 | + } |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @param string|resource $data |
|
66 | - * @throws NotPermittedException |
|
67 | - * @throws GenericFileException |
|
68 | - * @throws LockedException |
|
69 | - */ |
|
70 | - public function putContent($data) { |
|
71 | - if ($this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE)) { |
|
72 | - $this->sendHooks(['preWrite']); |
|
73 | - if ($this->view->file_put_contents($this->path, $data) === false) { |
|
74 | - throw new GenericFileException('file_put_contents failed'); |
|
75 | - } |
|
76 | - $this->fileInfo = null; |
|
77 | - $this->sendHooks(['postWrite']); |
|
78 | - } else { |
|
79 | - throw new NotPermittedException(); |
|
80 | - } |
|
81 | - } |
|
64 | + /** |
|
65 | + * @param string|resource $data |
|
66 | + * @throws NotPermittedException |
|
67 | + * @throws GenericFileException |
|
68 | + * @throws LockedException |
|
69 | + */ |
|
70 | + public function putContent($data) { |
|
71 | + if ($this->checkPermissions(\OCP\Constants::PERMISSION_UPDATE)) { |
|
72 | + $this->sendHooks(['preWrite']); |
|
73 | + if ($this->view->file_put_contents($this->path, $data) === false) { |
|
74 | + throw new GenericFileException('file_put_contents failed'); |
|
75 | + } |
|
76 | + $this->fileInfo = null; |
|
77 | + $this->sendHooks(['postWrite']); |
|
78 | + } else { |
|
79 | + throw new NotPermittedException(); |
|
80 | + } |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * @param string $mode |
|
85 | - * @return resource|false |
|
86 | - * @throws NotPermittedException |
|
87 | - * @throws LockedException |
|
88 | - */ |
|
89 | - public function fopen($mode) { |
|
90 | - $preHooks = []; |
|
91 | - $postHooks = []; |
|
92 | - $requiredPermissions = \OCP\Constants::PERMISSION_READ; |
|
93 | - switch ($mode) { |
|
94 | - case 'r+': |
|
95 | - case 'rb+': |
|
96 | - case 'w+': |
|
97 | - case 'wb+': |
|
98 | - case 'x+': |
|
99 | - case 'xb+': |
|
100 | - case 'a+': |
|
101 | - case 'ab+': |
|
102 | - case 'w': |
|
103 | - case 'wb': |
|
104 | - case 'x': |
|
105 | - case 'xb': |
|
106 | - case 'a': |
|
107 | - case 'ab': |
|
108 | - $preHooks[] = 'preWrite'; |
|
109 | - $postHooks[] = 'postWrite'; |
|
110 | - $requiredPermissions |= \OCP\Constants::PERMISSION_UPDATE; |
|
111 | - break; |
|
112 | - } |
|
83 | + /** |
|
84 | + * @param string $mode |
|
85 | + * @return resource|false |
|
86 | + * @throws NotPermittedException |
|
87 | + * @throws LockedException |
|
88 | + */ |
|
89 | + public function fopen($mode) { |
|
90 | + $preHooks = []; |
|
91 | + $postHooks = []; |
|
92 | + $requiredPermissions = \OCP\Constants::PERMISSION_READ; |
|
93 | + switch ($mode) { |
|
94 | + case 'r+': |
|
95 | + case 'rb+': |
|
96 | + case 'w+': |
|
97 | + case 'wb+': |
|
98 | + case 'x+': |
|
99 | + case 'xb+': |
|
100 | + case 'a+': |
|
101 | + case 'ab+': |
|
102 | + case 'w': |
|
103 | + case 'wb': |
|
104 | + case 'x': |
|
105 | + case 'xb': |
|
106 | + case 'a': |
|
107 | + case 'ab': |
|
108 | + $preHooks[] = 'preWrite'; |
|
109 | + $postHooks[] = 'postWrite'; |
|
110 | + $requiredPermissions |= \OCP\Constants::PERMISSION_UPDATE; |
|
111 | + break; |
|
112 | + } |
|
113 | 113 | |
114 | - if ($this->checkPermissions($requiredPermissions)) { |
|
115 | - $this->sendHooks($preHooks); |
|
116 | - $result = $this->view->fopen($this->path, $mode); |
|
117 | - $this->sendHooks($postHooks); |
|
118 | - return $result; |
|
119 | - } else { |
|
120 | - throw new NotPermittedException(); |
|
121 | - } |
|
122 | - } |
|
114 | + if ($this->checkPermissions($requiredPermissions)) { |
|
115 | + $this->sendHooks($preHooks); |
|
116 | + $result = $this->view->fopen($this->path, $mode); |
|
117 | + $this->sendHooks($postHooks); |
|
118 | + return $result; |
|
119 | + } else { |
|
120 | + throw new NotPermittedException(); |
|
121 | + } |
|
122 | + } |
|
123 | 123 | |
124 | - /** |
|
125 | - * @throws NotPermittedException |
|
126 | - * @throws \OCP\Files\InvalidPathException |
|
127 | - * @throws \OCP\Files\NotFoundException |
|
128 | - */ |
|
129 | - public function delete() { |
|
130 | - if ($this->checkPermissions(\OCP\Constants::PERMISSION_DELETE)) { |
|
131 | - $this->sendHooks(['preDelete']); |
|
132 | - $fileInfo = $this->getFileInfo(); |
|
133 | - $this->view->unlink($this->path); |
|
134 | - $nonExisting = new NonExistingFile($this->root, $this->view, $this->path, $fileInfo); |
|
135 | - $this->sendHooks(['postDelete'], [$nonExisting]); |
|
136 | - $this->fileInfo = null; |
|
137 | - } else { |
|
138 | - throw new NotPermittedException(); |
|
139 | - } |
|
140 | - } |
|
124 | + /** |
|
125 | + * @throws NotPermittedException |
|
126 | + * @throws \OCP\Files\InvalidPathException |
|
127 | + * @throws \OCP\Files\NotFoundException |
|
128 | + */ |
|
129 | + public function delete() { |
|
130 | + if ($this->checkPermissions(\OCP\Constants::PERMISSION_DELETE)) { |
|
131 | + $this->sendHooks(['preDelete']); |
|
132 | + $fileInfo = $this->getFileInfo(); |
|
133 | + $this->view->unlink($this->path); |
|
134 | + $nonExisting = new NonExistingFile($this->root, $this->view, $this->path, $fileInfo); |
|
135 | + $this->sendHooks(['postDelete'], [$nonExisting]); |
|
136 | + $this->fileInfo = null; |
|
137 | + } else { |
|
138 | + throw new NotPermittedException(); |
|
139 | + } |
|
140 | + } |
|
141 | 141 | |
142 | - /** |
|
143 | - * @param string $type |
|
144 | - * @param bool $raw |
|
145 | - * @return string |
|
146 | - */ |
|
147 | - public function hash($type, $raw = false) { |
|
148 | - return $this->view->hash($type, $this->path, $raw); |
|
149 | - } |
|
142 | + /** |
|
143 | + * @param string $type |
|
144 | + * @param bool $raw |
|
145 | + * @return string |
|
146 | + */ |
|
147 | + public function hash($type, $raw = false) { |
|
148 | + return $this->view->hash($type, $this->path, $raw); |
|
149 | + } |
|
150 | 150 | |
151 | - /** |
|
152 | - * @inheritdoc |
|
153 | - */ |
|
154 | - public function getChecksum() { |
|
155 | - return $this->getFileInfo()->getChecksum(); |
|
156 | - } |
|
151 | + /** |
|
152 | + * @inheritdoc |
|
153 | + */ |
|
154 | + public function getChecksum() { |
|
155 | + return $this->getFileInfo()->getChecksum(); |
|
156 | + } |
|
157 | 157 | |
158 | - public function getExtension(): string { |
|
159 | - return $this->getFileInfo()->getExtension(); |
|
160 | - } |
|
158 | + public function getExtension(): string { |
|
159 | + return $this->getFileInfo()->getExtension(); |
|
160 | + } |
|
161 | 161 | } |
@@ -30,26 +30,26 @@ |
||
30 | 30 | use Sabre\DAV\Server; |
31 | 31 | |
32 | 32 | class TooManyRequests extends NotAuthenticated { |
33 | - public const NS_OWNCLOUD = 'http://owncloud.org/ns'; |
|
34 | - |
|
35 | - public function getHTTPCode() { |
|
36 | - return 429; |
|
37 | - } |
|
38 | - |
|
39 | - /** |
|
40 | - * This method allows the exception to include additional information |
|
41 | - * into the WebDAV error response |
|
42 | - * |
|
43 | - * @param Server $server |
|
44 | - * @param DOMElement $errorNode |
|
45 | - * @return void |
|
46 | - */ |
|
47 | - public function serialize(Server $server, DOMElement $errorNode) { |
|
48 | - |
|
49 | - // set ownCloud namespace |
|
50 | - $errorNode->setAttribute('xmlns:o', self::NS_OWNCLOUD); |
|
51 | - |
|
52 | - $error = $errorNode->ownerDocument->createElementNS('o:', 'o:hint', 'too many requests'); |
|
53 | - $errorNode->appendChild($error); |
|
54 | - } |
|
33 | + public const NS_OWNCLOUD = 'http://owncloud.org/ns'; |
|
34 | + |
|
35 | + public function getHTTPCode() { |
|
36 | + return 429; |
|
37 | + } |
|
38 | + |
|
39 | + /** |
|
40 | + * This method allows the exception to include additional information |
|
41 | + * into the WebDAV error response |
|
42 | + * |
|
43 | + * @param Server $server |
|
44 | + * @param DOMElement $errorNode |
|
45 | + * @return void |
|
46 | + */ |
|
47 | + public function serialize(Server $server, DOMElement $errorNode) { |
|
48 | + |
|
49 | + // set ownCloud namespace |
|
50 | + $errorNode->setAttribute('xmlns:o', self::NS_OWNCLOUD); |
|
51 | + |
|
52 | + $error = $errorNode->ownerDocument->createElementNS('o:', 'o:hint', 'too many requests'); |
|
53 | + $errorNode->appendChild($error); |
|
54 | + } |
|
55 | 55 | } |
@@ -33,12 +33,12 @@ |
||
33 | 33 | * @since 25.0.0 |
34 | 34 | */ |
35 | 35 | interface ISizeEstimationMigrator { |
36 | - /** |
|
37 | - * Returns an estimate of the exported data size in KiB. |
|
38 | - * Should be fast, favor performance over accuracy. |
|
39 | - * |
|
40 | - * @since 25.0.0 |
|
41 | - * @since 27.0.0 return value may overflow from int to float |
|
42 | - */ |
|
43 | - public function getEstimatedExportSize(IUser $user): int|float; |
|
36 | + /** |
|
37 | + * Returns an estimate of the exported data size in KiB. |
|
38 | + * Should be fast, favor performance over accuracy. |
|
39 | + * |
|
40 | + * @since 25.0.0 |
|
41 | + * @since 27.0.0 return value may overflow from int to float |
|
42 | + */ |
|
43 | + public function getEstimatedExportSize(IUser $user): int|float; |
|
44 | 44 | } |
@@ -37,64 +37,64 @@ |
||
37 | 37 | * @since 22.0.0 |
38 | 38 | */ |
39 | 39 | interface IAccountPropertyCollection extends JsonSerializable { |
40 | - /** |
|
41 | - * returns the collection name |
|
42 | - * |
|
43 | - * @since 22.0.0 |
|
44 | - */ |
|
45 | - public function getName(): string; |
|
40 | + /** |
|
41 | + * returns the collection name |
|
42 | + * |
|
43 | + * @since 22.0.0 |
|
44 | + */ |
|
45 | + public function getName(): string; |
|
46 | 46 | |
47 | - /** |
|
48 | - * set properties of this collection |
|
49 | - * |
|
50 | - * @param IAccountProperty[] $properties |
|
51 | - * @throws InvalidArgumentException |
|
52 | - * @since 22.0.0 |
|
53 | - */ |
|
54 | - public function setProperties(array $properties): IAccountPropertyCollection; |
|
47 | + /** |
|
48 | + * set properties of this collection |
|
49 | + * |
|
50 | + * @param IAccountProperty[] $properties |
|
51 | + * @throws InvalidArgumentException |
|
52 | + * @since 22.0.0 |
|
53 | + */ |
|
54 | + public function setProperties(array $properties): IAccountPropertyCollection; |
|
55 | 55 | |
56 | - /** |
|
57 | - * @return IAccountProperty[] |
|
58 | - * @since 22.0.0 |
|
59 | - */ |
|
60 | - public function getProperties(): array; |
|
56 | + /** |
|
57 | + * @return IAccountProperty[] |
|
58 | + * @since 22.0.0 |
|
59 | + */ |
|
60 | + public function getProperties(): array; |
|
61 | 61 | |
62 | - /** |
|
63 | - * adds a property to this collection |
|
64 | - * |
|
65 | - * @throws InvalidArgumentException |
|
66 | - * @since 22.0.0 |
|
67 | - */ |
|
68 | - public function addProperty(IAccountProperty $property): IAccountPropertyCollection; |
|
62 | + /** |
|
63 | + * adds a property to this collection |
|
64 | + * |
|
65 | + * @throws InvalidArgumentException |
|
66 | + * @since 22.0.0 |
|
67 | + */ |
|
68 | + public function addProperty(IAccountProperty $property): IAccountPropertyCollection; |
|
69 | 69 | |
70 | - /** |
|
71 | - * adds a property to this collection with only specifying the value |
|
72 | - * |
|
73 | - * @throws InvalidArgumentException |
|
74 | - * @since 22.0.0 |
|
75 | - */ |
|
76 | - public function addPropertyWithDefaults(string $value): IAccountPropertyCollection; |
|
70 | + /** |
|
71 | + * adds a property to this collection with only specifying the value |
|
72 | + * |
|
73 | + * @throws InvalidArgumentException |
|
74 | + * @since 22.0.0 |
|
75 | + */ |
|
76 | + public function addPropertyWithDefaults(string $value): IAccountPropertyCollection; |
|
77 | 77 | |
78 | - /** |
|
79 | - * removes a property of this collection |
|
80 | - * |
|
81 | - * @since 22.0.0 |
|
82 | - */ |
|
83 | - public function removeProperty(IAccountProperty $property): IAccountPropertyCollection; |
|
78 | + /** |
|
79 | + * removes a property of this collection |
|
80 | + * |
|
81 | + * @since 22.0.0 |
|
82 | + */ |
|
83 | + public function removeProperty(IAccountProperty $property): IAccountPropertyCollection; |
|
84 | 84 | |
85 | - /** |
|
86 | - * removes a property identified by its value |
|
87 | - * |
|
88 | - * @since 22.0.0 |
|
89 | - */ |
|
90 | - public function removePropertyByValue(string $value): IAccountPropertyCollection; |
|
85 | + /** |
|
86 | + * removes a property identified by its value |
|
87 | + * |
|
88 | + * @since 22.0.0 |
|
89 | + */ |
|
90 | + public function removePropertyByValue(string $value): IAccountPropertyCollection; |
|
91 | 91 | |
92 | - /** |
|
93 | - * retrieves a property identified by its value. null, if none was found. |
|
94 | - * |
|
95 | - * Returns only the first property if there are more with the same value. |
|
96 | - * |
|
97 | - * @since 23.0.0 |
|
98 | - */ |
|
99 | - public function getPropertyByValue(string $value): ?IAccountProperty; |
|
92 | + /** |
|
93 | + * retrieves a property identified by its value. null, if none was found. |
|
94 | + * |
|
95 | + * Returns only the first property if there are more with the same value. |
|
96 | + * |
|
97 | + * @since 23.0.0 |
|
98 | + */ |
|
99 | + public function getPropertyByValue(string $value): ?IAccountProperty; |
|
100 | 100 | } |
@@ -31,68 +31,68 @@ |
||
31 | 31 | * @since 18.0.0 |
32 | 32 | */ |
33 | 33 | interface IEditor { |
34 | - /** |
|
35 | - * Return a unique identifier for the editor |
|
36 | - * |
|
37 | - * e.g. richdocuments |
|
38 | - * |
|
39 | - * @since 18.0.0 |
|
40 | - * @return string |
|
41 | - */ |
|
42 | - public function getId(): string; |
|
34 | + /** |
|
35 | + * Return a unique identifier for the editor |
|
36 | + * |
|
37 | + * e.g. richdocuments |
|
38 | + * |
|
39 | + * @since 18.0.0 |
|
40 | + * @return string |
|
41 | + */ |
|
42 | + public function getId(): string; |
|
43 | 43 | |
44 | - /** |
|
45 | - * Return a readable name for the editor |
|
46 | - * |
|
47 | - * e.g. Collabora Online |
|
48 | - * |
|
49 | - * @since 18.0.0 |
|
50 | - * @return string |
|
51 | - */ |
|
52 | - public function getName(): string; |
|
44 | + /** |
|
45 | + * Return a readable name for the editor |
|
46 | + * |
|
47 | + * e.g. Collabora Online |
|
48 | + * |
|
49 | + * @since 18.0.0 |
|
50 | + * @return string |
|
51 | + */ |
|
52 | + public function getName(): string; |
|
53 | 53 | |
54 | - /** |
|
55 | - * A list of mimetypes that should open the editor by default |
|
56 | - * |
|
57 | - * @since 18.0.0 |
|
58 | - * @return string[] |
|
59 | - */ |
|
60 | - public function getMimetypes(): array; |
|
54 | + /** |
|
55 | + * A list of mimetypes that should open the editor by default |
|
56 | + * |
|
57 | + * @since 18.0.0 |
|
58 | + * @return string[] |
|
59 | + */ |
|
60 | + public function getMimetypes(): array; |
|
61 | 61 | |
62 | - /** |
|
63 | - * A list of mimetypes that can be opened in the editor optionally |
|
64 | - * |
|
65 | - * @since 18.0.0 |
|
66 | - * @return string[] |
|
67 | - */ |
|
68 | - public function getMimetypesOptional(): array; |
|
62 | + /** |
|
63 | + * A list of mimetypes that can be opened in the editor optionally |
|
64 | + * |
|
65 | + * @since 18.0.0 |
|
66 | + * @return string[] |
|
67 | + */ |
|
68 | + public function getMimetypesOptional(): array; |
|
69 | 69 | |
70 | - /** |
|
71 | - * Return a list of file creation options to be presented to the user |
|
72 | - * |
|
73 | - * @since 18.0.0 |
|
74 | - * @return ACreateFromTemplate[]|ACreateEmpty[] |
|
75 | - */ |
|
76 | - public function getCreators(): array; |
|
70 | + /** |
|
71 | + * Return a list of file creation options to be presented to the user |
|
72 | + * |
|
73 | + * @since 18.0.0 |
|
74 | + * @return ACreateFromTemplate[]|ACreateEmpty[] |
|
75 | + */ |
|
76 | + public function getCreators(): array; |
|
77 | 77 | |
78 | - /** |
|
79 | - * Return if the view is able to securely view a file without downloading it to the browser |
|
80 | - * |
|
81 | - * @since 18.0.0 |
|
82 | - * @return bool |
|
83 | - */ |
|
84 | - public function isSecure(): bool; |
|
78 | + /** |
|
79 | + * Return if the view is able to securely view a file without downloading it to the browser |
|
80 | + * |
|
81 | + * @since 18.0.0 |
|
82 | + * @return bool |
|
83 | + */ |
|
84 | + public function isSecure(): bool; |
|
85 | 85 | |
86 | - /** |
|
87 | - * Return a template response for displaying the editor |
|
88 | - * |
|
89 | - * open can only be called once when the client requests the editor with a one-time-use token |
|
90 | - * For handling editing and later requests, editors need to implement their own token handling and take care of invalidation |
|
91 | - * |
|
92 | - * This behavior is similar to the current direct editing implementation in collabora where we generate a one-time token and switch over to the regular wopi token for the actual editing/saving process |
|
93 | - * |
|
94 | - * @since 18.0.0 |
|
95 | - * @return Response |
|
96 | - */ |
|
97 | - public function open(IToken $token): Response; |
|
86 | + /** |
|
87 | + * Return a template response for displaying the editor |
|
88 | + * |
|
89 | + * open can only be called once when the client requests the editor with a one-time-use token |
|
90 | + * For handling editing and later requests, editors need to implement their own token handling and take care of invalidation |
|
91 | + * |
|
92 | + * This behavior is similar to the current direct editing implementation in collabora where we generate a one-time token and switch over to the regular wopi token for the actual editing/saving process |
|
93 | + * |
|
94 | + * @since 18.0.0 |
|
95 | + * @return Response |
|
96 | + */ |
|
97 | + public function open(IToken $token): Response; |
|
98 | 98 | } |
@@ -31,38 +31,38 @@ |
||
31 | 31 | use OCP\Files\Cache\ICacheEntry; |
32 | 32 | |
33 | 33 | class HomeCache extends Cache { |
34 | - /** |
|
35 | - * get the size of a folder and set it in the cache |
|
36 | - * |
|
37 | - * @param string $path |
|
38 | - * @param array|null|ICacheEntry $entry (optional) meta data of the folder |
|
39 | - * @return int|float |
|
40 | - */ |
|
41 | - public function calculateFolderSize($path, $entry = null) { |
|
42 | - if ($path !== '/' and $path !== '' and $path !== 'files' and $path !== 'files_trashbin' and $path !== 'files_versions') { |
|
43 | - return parent::calculateFolderSize($path, $entry); |
|
44 | - } elseif ($path === '' or $path === '/') { |
|
45 | - // since the size of / isn't used (the size of /files is used instead) there is no use in calculating it |
|
46 | - return 0; |
|
47 | - } else { |
|
48 | - return $this->calculateFolderSizeInner($path, $entry, true); |
|
49 | - } |
|
50 | - } |
|
34 | + /** |
|
35 | + * get the size of a folder and set it in the cache |
|
36 | + * |
|
37 | + * @param string $path |
|
38 | + * @param array|null|ICacheEntry $entry (optional) meta data of the folder |
|
39 | + * @return int|float |
|
40 | + */ |
|
41 | + public function calculateFolderSize($path, $entry = null) { |
|
42 | + if ($path !== '/' and $path !== '' and $path !== 'files' and $path !== 'files_trashbin' and $path !== 'files_versions') { |
|
43 | + return parent::calculateFolderSize($path, $entry); |
|
44 | + } elseif ($path === '' or $path === '/') { |
|
45 | + // since the size of / isn't used (the size of /files is used instead) there is no use in calculating it |
|
46 | + return 0; |
|
47 | + } else { |
|
48 | + return $this->calculateFolderSizeInner($path, $entry, true); |
|
49 | + } |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * @param string $file |
|
54 | - * @return ICacheEntry |
|
55 | - */ |
|
56 | - public function get($file) { |
|
57 | - $data = parent::get($file); |
|
58 | - if ($file === '' or $file === '/') { |
|
59 | - // only the size of the "files" dir counts |
|
60 | - $filesData = parent::get('files'); |
|
52 | + /** |
|
53 | + * @param string $file |
|
54 | + * @return ICacheEntry |
|
55 | + */ |
|
56 | + public function get($file) { |
|
57 | + $data = parent::get($file); |
|
58 | + if ($file === '' or $file === '/') { |
|
59 | + // only the size of the "files" dir counts |
|
60 | + $filesData = parent::get('files'); |
|
61 | 61 | |
62 | - if (isset($filesData['size'])) { |
|
63 | - $data['size'] = $filesData['size']; |
|
64 | - } |
|
65 | - } |
|
66 | - return $data; |
|
67 | - } |
|
62 | + if (isset($filesData['size'])) { |
|
63 | + $data['size'] = $filesData['size']; |
|
64 | + } |
|
65 | + } |
|
66 | + return $data; |
|
67 | + } |
|
68 | 68 | } |
@@ -37,70 +37,70 @@ |
||
37 | 37 | * @since 24.0.0 |
38 | 38 | */ |
39 | 39 | trait TTransactional { |
40 | - /** |
|
41 | - * Run an atomic database operation |
|
42 | - * |
|
43 | - * - Commit if no exceptions are thrown, return the callable result |
|
44 | - * - Revert otherwise and rethrows the exception |
|
45 | - * |
|
46 | - * @template T |
|
47 | - * @param callable $fn |
|
48 | - * @psalm-param callable():T $fn |
|
49 | - * @param IDBConnection $db |
|
50 | - * |
|
51 | - * @return mixed the result of the passed callable |
|
52 | - * @psalm-return T |
|
53 | - * |
|
54 | - * @throws Exception for possible errors of commit or rollback or the custom operations within the closure |
|
55 | - * @throws Throwable any other error caused by the closure |
|
56 | - * |
|
57 | - * @since 24.0.0 |
|
58 | - * @see https://docs.nextcloud.com/server/latest/developer_manual/basics/storage/database.html#transactions |
|
59 | - */ |
|
60 | - protected function atomic(callable $fn, IDBConnection $db) { |
|
61 | - $db->beginTransaction(); |
|
62 | - try { |
|
63 | - $result = $fn(); |
|
64 | - $db->commit(); |
|
65 | - return $result; |
|
66 | - } catch (Throwable $e) { |
|
67 | - $db->rollBack(); |
|
68 | - throw $e; |
|
69 | - } |
|
70 | - } |
|
40 | + /** |
|
41 | + * Run an atomic database operation |
|
42 | + * |
|
43 | + * - Commit if no exceptions are thrown, return the callable result |
|
44 | + * - Revert otherwise and rethrows the exception |
|
45 | + * |
|
46 | + * @template T |
|
47 | + * @param callable $fn |
|
48 | + * @psalm-param callable():T $fn |
|
49 | + * @param IDBConnection $db |
|
50 | + * |
|
51 | + * @return mixed the result of the passed callable |
|
52 | + * @psalm-return T |
|
53 | + * |
|
54 | + * @throws Exception for possible errors of commit or rollback or the custom operations within the closure |
|
55 | + * @throws Throwable any other error caused by the closure |
|
56 | + * |
|
57 | + * @since 24.0.0 |
|
58 | + * @see https://docs.nextcloud.com/server/latest/developer_manual/basics/storage/database.html#transactions |
|
59 | + */ |
|
60 | + protected function atomic(callable $fn, IDBConnection $db) { |
|
61 | + $db->beginTransaction(); |
|
62 | + try { |
|
63 | + $result = $fn(); |
|
64 | + $db->commit(); |
|
65 | + return $result; |
|
66 | + } catch (Throwable $e) { |
|
67 | + $db->rollBack(); |
|
68 | + throw $e; |
|
69 | + } |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * Wrapper around atomic() to retry after a retryable exception occurred |
|
74 | - * |
|
75 | - * Certain transactions might need to be retried. This is especially useful |
|
76 | - * in highly concurrent requests where a deadlocks is thrown by the database |
|
77 | - * without waiting for the lock to be freed (e.g. due to MySQL/MariaDB deadlock |
|
78 | - * detection) |
|
79 | - * |
|
80 | - * @template T |
|
81 | - * @param callable $fn |
|
82 | - * @psalm-param callable():T $fn |
|
83 | - * @param IDBConnection $db |
|
84 | - * @param int $maxRetries |
|
85 | - * |
|
86 | - * @return mixed the result of the passed callable |
|
87 | - * @psalm-return T |
|
88 | - * |
|
89 | - * @throws Exception for possible errors of commit or rollback or the custom operations within the closure |
|
90 | - * @throws Throwable any other error caused by the closure |
|
91 | - * |
|
92 | - * @since 27.0.0 |
|
93 | - */ |
|
94 | - protected function atomicRetry(callable $fn, IDBConnection $db, int $maxRetries = 3): mixed { |
|
95 | - for ($i = 0; $i < $maxRetries; $i++) { |
|
96 | - try { |
|
97 | - return $this->atomic($fn, $db); |
|
98 | - } catch (DbalException $e) { |
|
99 | - if (!$e->isRetryable() || $i === ($maxRetries - 1)) { |
|
100 | - throw $e; |
|
101 | - } |
|
102 | - logger('core')->warning('Retrying operation after retryable exception.', [ 'exception' => $e ]); |
|
103 | - } |
|
104 | - } |
|
105 | - } |
|
72 | + /** |
|
73 | + * Wrapper around atomic() to retry after a retryable exception occurred |
|
74 | + * |
|
75 | + * Certain transactions might need to be retried. This is especially useful |
|
76 | + * in highly concurrent requests where a deadlocks is thrown by the database |
|
77 | + * without waiting for the lock to be freed (e.g. due to MySQL/MariaDB deadlock |
|
78 | + * detection) |
|
79 | + * |
|
80 | + * @template T |
|
81 | + * @param callable $fn |
|
82 | + * @psalm-param callable():T $fn |
|
83 | + * @param IDBConnection $db |
|
84 | + * @param int $maxRetries |
|
85 | + * |
|
86 | + * @return mixed the result of the passed callable |
|
87 | + * @psalm-return T |
|
88 | + * |
|
89 | + * @throws Exception for possible errors of commit or rollback or the custom operations within the closure |
|
90 | + * @throws Throwable any other error caused by the closure |
|
91 | + * |
|
92 | + * @since 27.0.0 |
|
93 | + */ |
|
94 | + protected function atomicRetry(callable $fn, IDBConnection $db, int $maxRetries = 3): mixed { |
|
95 | + for ($i = 0; $i < $maxRetries; $i++) { |
|
96 | + try { |
|
97 | + return $this->atomic($fn, $db); |
|
98 | + } catch (DbalException $e) { |
|
99 | + if (!$e->isRetryable() || $i === ($maxRetries - 1)) { |
|
100 | + throw $e; |
|
101 | + } |
|
102 | + logger('core')->warning('Retrying operation after retryable exception.', [ 'exception' => $e ]); |
|
103 | + } |
|
104 | + } |
|
105 | + } |
|
106 | 106 | } |