@@ -28,43 +28,43 @@ |
||
28 | 28 | |
29 | 29 | class LazyL10N implements IL10N { |
30 | 30 | |
31 | - /** @var IL10N */ |
|
32 | - private $l; |
|
31 | + /** @var IL10N */ |
|
32 | + private $l; |
|
33 | 33 | |
34 | - /** @var \Closure */ |
|
35 | - private $factory; |
|
34 | + /** @var \Closure */ |
|
35 | + private $factory; |
|
36 | 36 | |
37 | 37 | |
38 | - public function __construct(\Closure $factory) { |
|
39 | - $this->factory = $factory; |
|
40 | - } |
|
38 | + public function __construct(\Closure $factory) { |
|
39 | + $this->factory = $factory; |
|
40 | + } |
|
41 | 41 | |
42 | - private function getL(): IL10N { |
|
43 | - if ($this->l === null) { |
|
44 | - $this->l = ($this->factory)(); |
|
45 | - } |
|
42 | + private function getL(): IL10N { |
|
43 | + if ($this->l === null) { |
|
44 | + $this->l = ($this->factory)(); |
|
45 | + } |
|
46 | 46 | |
47 | - return $this->l; |
|
48 | - } |
|
47 | + return $this->l; |
|
48 | + } |
|
49 | 49 | |
50 | - public function t(string $text, $parameters = []): string { |
|
51 | - return $this->getL()->t($text, $parameters); |
|
52 | - } |
|
50 | + public function t(string $text, $parameters = []): string { |
|
51 | + return $this->getL()->t($text, $parameters); |
|
52 | + } |
|
53 | 53 | |
54 | - public function n(string $text_singular, string $text_plural, int $count, array $parameters = []): string { |
|
55 | - return $this->getL()->n($text_singular, $text_plural, $count, $parameters); |
|
56 | - } |
|
54 | + public function n(string $text_singular, string $text_plural, int $count, array $parameters = []): string { |
|
55 | + return $this->getL()->n($text_singular, $text_plural, $count, $parameters); |
|
56 | + } |
|
57 | 57 | |
58 | - public function l(string $type, $data, array $options = []) { |
|
59 | - return $this->getL()->l($type, $data, $options); |
|
60 | - } |
|
58 | + public function l(string $type, $data, array $options = []) { |
|
59 | + return $this->getL()->l($type, $data, $options); |
|
60 | + } |
|
61 | 61 | |
62 | - public function getLanguageCode(): string { |
|
63 | - return $this->getL()->getLanguageCode(); |
|
64 | - } |
|
62 | + public function getLanguageCode(): string { |
|
63 | + return $this->getL()->getLanguageCode(); |
|
64 | + } |
|
65 | 65 | |
66 | - public function getLocaleCode(): string { |
|
67 | - return $this->getL()->getLocaleCode(); |
|
68 | - } |
|
66 | + public function getLocaleCode(): string { |
|
67 | + return $this->getL()->getLocaleCode(); |
|
68 | + } |
|
69 | 69 | |
70 | 70 | } |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | throw new \Exception('missing IObjectStore instance'); |
58 | 58 | } |
59 | 59 | if (isset($params['storageid'])) { |
60 | - $this->id = 'object::store:' . $params['storageid']; |
|
60 | + $this->id = 'object::store:'.$params['storageid']; |
|
61 | 61 | } else { |
62 | - $this->id = 'object::store:' . $this->objectStore->getStorageId(); |
|
62 | + $this->id = 'object::store:'.$this->objectStore->getStorageId(); |
|
63 | 63 | } |
64 | 64 | if (isset($params['objectPrefix'])) { |
65 | 65 | $this->objectPrefix = $params['objectPrefix']; |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | if ($ex->getCode() !== 404) { |
194 | 194 | $this->logger->logException($ex, [ |
195 | 195 | 'app' => 'objectstore', |
196 | - 'message' => 'Could not delete object ' . $this->getURN($stat['fileid']) . ' for ' . $path, |
|
196 | + 'message' => 'Could not delete object '.$this->getURN($stat['fileid']).' for '.$path, |
|
197 | 197 | ]); |
198 | 198 | return false; |
199 | 199 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | */ |
226 | 226 | public function getURN($fileId) { |
227 | 227 | if (is_numeric($fileId)) { |
228 | - return $this->objectPrefix . $fileId; |
|
228 | + return $this->objectPrefix.$fileId; |
|
229 | 229 | } |
230 | 230 | return null; |
231 | 231 | } |
@@ -279,13 +279,13 @@ discard block |
||
279 | 279 | } catch (NotFoundException $e) { |
280 | 280 | $this->logger->logException($e, [ |
281 | 281 | 'app' => 'objectstore', |
282 | - 'message' => 'Could not get object ' . $this->getURN($stat['fileid']) . ' for file ' . $path, |
|
282 | + 'message' => 'Could not get object '.$this->getURN($stat['fileid']).' for file '.$path, |
|
283 | 283 | ]); |
284 | 284 | throw $e; |
285 | 285 | } catch (\Exception $ex) { |
286 | 286 | $this->logger->logException($ex, [ |
287 | 287 | 'app' => 'objectstore', |
288 | - 'message' => 'Could not get object ' . $this->getURN($stat['fileid']) . ' for file ' . $path, |
|
288 | + 'message' => 'Could not get object '.$this->getURN($stat['fileid']).' for file '.$path, |
|
289 | 289 | ]); |
290 | 290 | return false; |
291 | 291 | } |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | case 'wb+': |
299 | 299 | $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext); |
300 | 300 | $handle = fopen($tmpFile, $mode); |
301 | - return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) { |
|
301 | + return CallbackWrapper::wrap($handle, null, null, function() use ($path, $tmpFile) { |
|
302 | 302 | $this->writeBack($tmpFile, $path); |
303 | 303 | }); |
304 | 304 | case 'a': |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | file_put_contents($tmpFile, $source); |
316 | 316 | } |
317 | 317 | $handle = fopen($tmpFile, $mode); |
318 | - return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) { |
|
318 | + return CallbackWrapper::wrap($handle, null, null, function() use ($path, $tmpFile) { |
|
319 | 319 | $this->writeBack($tmpFile, $path); |
320 | 320 | }); |
321 | 321 | } |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | |
325 | 325 | public function file_exists($path) { |
326 | 326 | $path = $this->normalizePath($path); |
327 | - return (bool)$this->stat($path); |
|
327 | + return (bool) $this->stat($path); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | public function rename($source, $target) { |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | } catch (\Exception $ex) { |
382 | 382 | $this->logger->logException($ex, [ |
383 | 383 | 'app' => 'objectstore', |
384 | - 'message' => 'Could not create object for ' . $path, |
|
384 | + 'message' => 'Could not create object for '.$path, |
|
385 | 385 | ]); |
386 | 386 | throw $ex; |
387 | 387 | } |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | } |
427 | 427 | // update stat with new data |
428 | 428 | $mTime = time(); |
429 | - $stat['size'] = (int)$size; |
|
429 | + $stat['size'] = (int) $size; |
|
430 | 430 | $stat['mtime'] = $mTime; |
431 | 431 | $stat['storage_mtime'] = $mTime; |
432 | 432 | |
@@ -437,13 +437,13 @@ discard block |
||
437 | 437 | $stat['etag'] = $this->getETag($path); |
438 | 438 | |
439 | 439 | $exists = $this->getCache()->inCache($path); |
440 | - $uploadPath = $exists ? $path : $path . '.part'; |
|
440 | + $uploadPath = $exists ? $path : $path.'.part'; |
|
441 | 441 | $fileId = $this->getCache()->put($uploadPath, $stat); |
442 | 442 | $urn = $this->getURN($fileId); |
443 | 443 | try { |
444 | 444 | //upload to object storage |
445 | 445 | if ($size === null) { |
446 | - $countStream = CountWrapper::wrap($stream, function ($writtenSize) use ($fileId, &$size) { |
|
446 | + $countStream = CountWrapper::wrap($stream, function($writtenSize) use ($fileId, &$size) { |
|
447 | 447 | $this->getCache()->update($fileId, [ |
448 | 448 | 'size' => $writtenSize |
449 | 449 | ]); |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | $this->getCache()->remove($uploadPath); |
461 | 461 | $this->logger->logException($ex, [ |
462 | 462 | 'app' => 'objectstore', |
463 | - 'message' => 'Could not create object ' . $urn . ' for ' . $path, |
|
463 | + 'message' => 'Could not create object '.$urn.' for '.$path, |
|
464 | 464 | ]); |
465 | 465 | throw $ex; // make this bubble up |
466 | 466 | } |
@@ -37,455 +37,455 @@ |
||
37 | 37 | use OCP\Files\ObjectStore\IObjectStore; |
38 | 38 | |
39 | 39 | class ObjectStoreStorage extends \OC\Files\Storage\Common { |
40 | - /** |
|
41 | - * @var \OCP\Files\ObjectStore\IObjectStore $objectStore |
|
42 | - */ |
|
43 | - protected $objectStore; |
|
44 | - /** |
|
45 | - * @var string $id |
|
46 | - */ |
|
47 | - protected $id; |
|
48 | - /** |
|
49 | - * @var \OC\User\User $user |
|
50 | - */ |
|
51 | - protected $user; |
|
52 | - |
|
53 | - private $objectPrefix = 'urn:oid:'; |
|
54 | - |
|
55 | - private $logger; |
|
56 | - |
|
57 | - public function __construct($params) { |
|
58 | - if (isset($params['objectstore']) && $params['objectstore'] instanceof IObjectStore) { |
|
59 | - $this->objectStore = $params['objectstore']; |
|
60 | - } else { |
|
61 | - throw new \Exception('missing IObjectStore instance'); |
|
62 | - } |
|
63 | - if (isset($params['storageid'])) { |
|
64 | - $this->id = 'object::store:' . $params['storageid']; |
|
65 | - } else { |
|
66 | - $this->id = 'object::store:' . $this->objectStore->getStorageId(); |
|
67 | - } |
|
68 | - if (isset($params['objectPrefix'])) { |
|
69 | - $this->objectPrefix = $params['objectPrefix']; |
|
70 | - } |
|
71 | - //initialize cache with root directory in cache |
|
72 | - if (!$this->is_dir('/')) { |
|
73 | - $this->mkdir('/'); |
|
74 | - } |
|
75 | - |
|
76 | - $this->logger = \OC::$server->getLogger(); |
|
77 | - } |
|
78 | - |
|
79 | - public function mkdir($path) { |
|
80 | - $path = $this->normalizePath($path); |
|
81 | - |
|
82 | - if ($this->file_exists($path)) { |
|
83 | - return false; |
|
84 | - } |
|
85 | - |
|
86 | - $mTime = time(); |
|
87 | - $data = [ |
|
88 | - 'mimetype' => 'httpd/unix-directory', |
|
89 | - 'size' => 0, |
|
90 | - 'mtime' => $mTime, |
|
91 | - 'storage_mtime' => $mTime, |
|
92 | - 'permissions' => \OCP\Constants::PERMISSION_ALL, |
|
93 | - ]; |
|
94 | - if ($path === '') { |
|
95 | - //create root on the fly |
|
96 | - $data['etag'] = $this->getETag(''); |
|
97 | - $this->getCache()->put('', $data); |
|
98 | - return true; |
|
99 | - } else { |
|
100 | - // if parent does not exist, create it |
|
101 | - $parent = $this->normalizePath(dirname($path)); |
|
102 | - $parentType = $this->filetype($parent); |
|
103 | - if ($parentType === false) { |
|
104 | - if (!$this->mkdir($parent)) { |
|
105 | - // something went wrong |
|
106 | - return false; |
|
107 | - } |
|
108 | - } elseif ($parentType === 'file') { |
|
109 | - // parent is a file |
|
110 | - return false; |
|
111 | - } |
|
112 | - // finally create the new dir |
|
113 | - $mTime = time(); // update mtime |
|
114 | - $data['mtime'] = $mTime; |
|
115 | - $data['storage_mtime'] = $mTime; |
|
116 | - $data['etag'] = $this->getETag($path); |
|
117 | - $this->getCache()->put($path, $data); |
|
118 | - return true; |
|
119 | - } |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * @param string $path |
|
124 | - * @return string |
|
125 | - */ |
|
126 | - private function normalizePath($path) { |
|
127 | - $path = trim($path, '/'); |
|
128 | - //FIXME why do we sometimes get a path like 'files//username'? |
|
129 | - $path = str_replace('//', '/', $path); |
|
130 | - |
|
131 | - // dirname('/folder') returns '.' but internally (in the cache) we store the root as '' |
|
132 | - if (!$path || $path === '.') { |
|
133 | - $path = ''; |
|
134 | - } |
|
135 | - |
|
136 | - return $path; |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * Object Stores use a NoopScanner because metadata is directly stored in |
|
141 | - * the file cache and cannot really scan the filesystem. The storage passed in is not used anywhere. |
|
142 | - * |
|
143 | - * @param string $path |
|
144 | - * @param \OC\Files\Storage\Storage (optional) the storage to pass to the scanner |
|
145 | - * @return \OC\Files\ObjectStore\NoopScanner |
|
146 | - */ |
|
147 | - public function getScanner($path = '', $storage = null) { |
|
148 | - if (!$storage) { |
|
149 | - $storage = $this; |
|
150 | - } |
|
151 | - if (!isset($this->scanner)) { |
|
152 | - $this->scanner = new NoopScanner($storage); |
|
153 | - } |
|
154 | - return $this->scanner; |
|
155 | - } |
|
156 | - |
|
157 | - public function getId() { |
|
158 | - return $this->id; |
|
159 | - } |
|
160 | - |
|
161 | - public function rmdir($path) { |
|
162 | - $path = $this->normalizePath($path); |
|
163 | - |
|
164 | - if (!$this->is_dir($path)) { |
|
165 | - return false; |
|
166 | - } |
|
167 | - |
|
168 | - if (!$this->rmObjects($path)) { |
|
169 | - return false; |
|
170 | - } |
|
171 | - |
|
172 | - $this->getCache()->remove($path); |
|
173 | - |
|
174 | - return true; |
|
175 | - } |
|
176 | - |
|
177 | - private function rmObjects($path) { |
|
178 | - $children = $this->getCache()->getFolderContents($path); |
|
179 | - foreach ($children as $child) { |
|
180 | - if ($child['mimetype'] === 'httpd/unix-directory') { |
|
181 | - if (!$this->rmObjects($child['path'])) { |
|
182 | - return false; |
|
183 | - } |
|
184 | - } else { |
|
185 | - if (!$this->unlink($child['path'])) { |
|
186 | - return false; |
|
187 | - } |
|
188 | - } |
|
189 | - } |
|
190 | - |
|
191 | - return true; |
|
192 | - } |
|
193 | - |
|
194 | - public function unlink($path) { |
|
195 | - $path = $this->normalizePath($path); |
|
196 | - $stat = $this->stat($path); |
|
197 | - |
|
198 | - if ($stat && isset($stat['fileid'])) { |
|
199 | - if ($stat['mimetype'] === 'httpd/unix-directory') { |
|
200 | - return $this->rmdir($path); |
|
201 | - } |
|
202 | - try { |
|
203 | - $this->objectStore->deleteObject($this->getURN($stat['fileid'])); |
|
204 | - } catch (\Exception $ex) { |
|
205 | - if ($ex->getCode() !== 404) { |
|
206 | - $this->logger->logException($ex, [ |
|
207 | - 'app' => 'objectstore', |
|
208 | - 'message' => 'Could not delete object ' . $this->getURN($stat['fileid']) . ' for ' . $path, |
|
209 | - ]); |
|
210 | - return false; |
|
211 | - } |
|
212 | - //removing from cache is ok as it does not exist in the objectstore anyway |
|
213 | - } |
|
214 | - $this->getCache()->remove($path); |
|
215 | - return true; |
|
216 | - } |
|
217 | - return false; |
|
218 | - } |
|
219 | - |
|
220 | - public function stat($path) { |
|
221 | - $path = $this->normalizePath($path); |
|
222 | - $cacheEntry = $this->getCache()->get($path); |
|
223 | - if ($cacheEntry instanceof CacheEntry) { |
|
224 | - return $cacheEntry->getData(); |
|
225 | - } else { |
|
226 | - return false; |
|
227 | - } |
|
228 | - } |
|
229 | - |
|
230 | - /** |
|
231 | - * Override this method if you need a different unique resource identifier for your object storage implementation. |
|
232 | - * The default implementations just appends the fileId to 'urn:oid:'. Make sure the URN is unique over all users. |
|
233 | - * You may need a mapping table to store your URN if it cannot be generated from the fileid. |
|
234 | - * |
|
235 | - * @param int $fileId the fileid |
|
236 | - * @return null|string the unified resource name used to identify the object |
|
237 | - */ |
|
238 | - public function getURN($fileId) { |
|
239 | - if (is_numeric($fileId)) { |
|
240 | - return $this->objectPrefix . $fileId; |
|
241 | - } |
|
242 | - return null; |
|
243 | - } |
|
244 | - |
|
245 | - public function opendir($path) { |
|
246 | - $path = $this->normalizePath($path); |
|
247 | - |
|
248 | - try { |
|
249 | - $files = []; |
|
250 | - $folderContents = $this->getCache()->getFolderContents($path); |
|
251 | - foreach ($folderContents as $file) { |
|
252 | - $files[] = $file['name']; |
|
253 | - } |
|
254 | - |
|
255 | - return IteratorDirectory::wrap($files); |
|
256 | - } catch (\Exception $e) { |
|
257 | - $this->logger->logException($e); |
|
258 | - return false; |
|
259 | - } |
|
260 | - } |
|
261 | - |
|
262 | - public function filetype($path) { |
|
263 | - $path = $this->normalizePath($path); |
|
264 | - $stat = $this->stat($path); |
|
265 | - if ($stat) { |
|
266 | - if ($stat['mimetype'] === 'httpd/unix-directory') { |
|
267 | - return 'dir'; |
|
268 | - } |
|
269 | - return 'file'; |
|
270 | - } else { |
|
271 | - return false; |
|
272 | - } |
|
273 | - } |
|
274 | - |
|
275 | - public function fopen($path, $mode) { |
|
276 | - $path = $this->normalizePath($path); |
|
277 | - |
|
278 | - if (strrpos($path, '.') !== false) { |
|
279 | - $ext = substr($path, strrpos($path, '.')); |
|
280 | - } else { |
|
281 | - $ext = ''; |
|
282 | - } |
|
283 | - |
|
284 | - switch ($mode) { |
|
285 | - case 'r': |
|
286 | - case 'rb': |
|
287 | - $stat = $this->stat($path); |
|
288 | - if (is_array($stat)) { |
|
289 | - try { |
|
290 | - return $this->objectStore->readObject($this->getURN($stat['fileid'])); |
|
291 | - } catch (NotFoundException $e) { |
|
292 | - $this->logger->logException($e, [ |
|
293 | - 'app' => 'objectstore', |
|
294 | - 'message' => 'Could not get object ' . $this->getURN($stat['fileid']) . ' for file ' . $path, |
|
295 | - ]); |
|
296 | - throw $e; |
|
297 | - } catch (\Exception $ex) { |
|
298 | - $this->logger->logException($ex, [ |
|
299 | - 'app' => 'objectstore', |
|
300 | - 'message' => 'Could not get object ' . $this->getURN($stat['fileid']) . ' for file ' . $path, |
|
301 | - ]); |
|
302 | - return false; |
|
303 | - } |
|
304 | - } else { |
|
305 | - return false; |
|
306 | - } |
|
307 | - // no break |
|
308 | - case 'w': |
|
309 | - case 'wb': |
|
310 | - case 'w+': |
|
311 | - case 'wb+': |
|
312 | - $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext); |
|
313 | - $handle = fopen($tmpFile, $mode); |
|
314 | - return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) { |
|
315 | - $this->writeBack($tmpFile, $path); |
|
316 | - }); |
|
317 | - case 'a': |
|
318 | - case 'ab': |
|
319 | - case 'r+': |
|
320 | - case 'a+': |
|
321 | - case 'x': |
|
322 | - case 'x+': |
|
323 | - case 'c': |
|
324 | - case 'c+': |
|
325 | - $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext); |
|
326 | - if ($this->file_exists($path)) { |
|
327 | - $source = $this->fopen($path, 'r'); |
|
328 | - file_put_contents($tmpFile, $source); |
|
329 | - } |
|
330 | - $handle = fopen($tmpFile, $mode); |
|
331 | - return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) { |
|
332 | - $this->writeBack($tmpFile, $path); |
|
333 | - }); |
|
334 | - } |
|
335 | - return false; |
|
336 | - } |
|
337 | - |
|
338 | - public function file_exists($path) { |
|
339 | - $path = $this->normalizePath($path); |
|
340 | - return (bool)$this->stat($path); |
|
341 | - } |
|
342 | - |
|
343 | - public function rename($source, $target) { |
|
344 | - $source = $this->normalizePath($source); |
|
345 | - $target = $this->normalizePath($target); |
|
346 | - $this->remove($target); |
|
347 | - $this->getCache()->move($source, $target); |
|
348 | - $this->touch(dirname($target)); |
|
349 | - return true; |
|
350 | - } |
|
351 | - |
|
352 | - public function getMimeType($path) { |
|
353 | - $path = $this->normalizePath($path); |
|
354 | - return parent::getMimeType($path); |
|
355 | - } |
|
356 | - |
|
357 | - public function touch($path, $mtime = null) { |
|
358 | - if (is_null($mtime)) { |
|
359 | - $mtime = time(); |
|
360 | - } |
|
361 | - |
|
362 | - $path = $this->normalizePath($path); |
|
363 | - $dirName = dirname($path); |
|
364 | - $parentExists = $this->is_dir($dirName); |
|
365 | - if (!$parentExists) { |
|
366 | - return false; |
|
367 | - } |
|
368 | - |
|
369 | - $stat = $this->stat($path); |
|
370 | - if (is_array($stat)) { |
|
371 | - // update existing mtime in db |
|
372 | - $stat['mtime'] = $mtime; |
|
373 | - $this->getCache()->update($stat['fileid'], $stat); |
|
374 | - } else { |
|
375 | - try { |
|
376 | - //create a empty file, need to have at least on char to make it |
|
377 | - // work with all object storage implementations |
|
378 | - $this->file_put_contents($path, ' '); |
|
379 | - $mimeType = \OC::$server->getMimeTypeDetector()->detectPath($path); |
|
380 | - $stat = [ |
|
381 | - 'etag' => $this->getETag($path), |
|
382 | - 'mimetype' => $mimeType, |
|
383 | - 'size' => 0, |
|
384 | - 'mtime' => $mtime, |
|
385 | - 'storage_mtime' => $mtime, |
|
386 | - 'permissions' => \OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_CREATE, |
|
387 | - ]; |
|
388 | - $this->getCache()->put($path, $stat); |
|
389 | - } catch (\Exception $ex) { |
|
390 | - $this->logger->logException($ex, [ |
|
391 | - 'app' => 'objectstore', |
|
392 | - 'message' => 'Could not create object for ' . $path, |
|
393 | - ]); |
|
394 | - throw $ex; |
|
395 | - } |
|
396 | - } |
|
397 | - return true; |
|
398 | - } |
|
399 | - |
|
400 | - public function writeBack($tmpFile, $path) { |
|
401 | - $size = filesize($tmpFile); |
|
402 | - $this->writeStream($path, fopen($tmpFile, 'r'), $size); |
|
403 | - } |
|
404 | - |
|
405 | - /** |
|
406 | - * external changes are not supported, exclusive access to the object storage is assumed |
|
407 | - * |
|
408 | - * @param string $path |
|
409 | - * @param int $time |
|
410 | - * @return false |
|
411 | - */ |
|
412 | - public function hasUpdated($path, $time) { |
|
413 | - return false; |
|
414 | - } |
|
415 | - |
|
416 | - public function needsPartFile() { |
|
417 | - return false; |
|
418 | - } |
|
419 | - |
|
420 | - public function file_put_contents($path, $data) { |
|
421 | - $handle = $this->fopen($path, 'w+'); |
|
422 | - fwrite($handle, $data); |
|
423 | - fclose($handle); |
|
424 | - return true; |
|
425 | - } |
|
426 | - |
|
427 | - public function writeStream(string $path, $stream, int $size = null): int { |
|
428 | - $stat = $this->stat($path); |
|
429 | - if (empty($stat)) { |
|
430 | - // create new file |
|
431 | - $stat = [ |
|
432 | - 'permissions' => \OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_CREATE, |
|
433 | - ]; |
|
434 | - } |
|
435 | - // update stat with new data |
|
436 | - $mTime = time(); |
|
437 | - $stat['size'] = (int)$size; |
|
438 | - $stat['mtime'] = $mTime; |
|
439 | - $stat['storage_mtime'] = $mTime; |
|
440 | - |
|
441 | - $mimetypeDetector = \OC::$server->getMimeTypeDetector(); |
|
442 | - $mimetype = $mimetypeDetector->detectPath($path); |
|
443 | - |
|
444 | - $stat['mimetype'] = $mimetype; |
|
445 | - $stat['etag'] = $this->getETag($path); |
|
446 | - |
|
447 | - $exists = $this->getCache()->inCache($path); |
|
448 | - $uploadPath = $exists ? $path : $path . '.part'; |
|
449 | - $fileId = $this->getCache()->put($uploadPath, $stat); |
|
450 | - $urn = $this->getURN($fileId); |
|
451 | - try { |
|
452 | - //upload to object storage |
|
453 | - if ($size === null) { |
|
454 | - $countStream = CountWrapper::wrap($stream, function ($writtenSize) use ($fileId, &$size) { |
|
455 | - $this->getCache()->update($fileId, [ |
|
456 | - 'size' => $writtenSize |
|
457 | - ]); |
|
458 | - $size = $writtenSize; |
|
459 | - }); |
|
460 | - $this->objectStore->writeObject($urn, $countStream); |
|
461 | - if (is_resource($countStream)) { |
|
462 | - fclose($countStream); |
|
463 | - } |
|
464 | - } else { |
|
465 | - $this->objectStore->writeObject($urn, $stream); |
|
466 | - } |
|
467 | - } catch (\Exception $ex) { |
|
468 | - $this->getCache()->remove($uploadPath); |
|
469 | - $this->logger->logException($ex, [ |
|
470 | - 'app' => 'objectstore', |
|
471 | - 'message' => 'Could not create object ' . $urn . ' for ' . $path, |
|
472 | - ]); |
|
473 | - throw $ex; // make this bubble up |
|
474 | - } |
|
475 | - |
|
476 | - if (!$exists) { |
|
477 | - if ($this->objectStore->objectExists($urn)) { |
|
478 | - $this->getCache()->move($uploadPath, $path); |
|
479 | - } else { |
|
480 | - $this->getCache()->remove($uploadPath); |
|
481 | - throw new \Exception("Object not found after writing (urn: $urn, path: $path)", 404); |
|
482 | - } |
|
483 | - } |
|
484 | - |
|
485 | - return $size; |
|
486 | - } |
|
487 | - |
|
488 | - public function getObjectStore(): IObjectStore { |
|
489 | - return $this->objectStore; |
|
490 | - } |
|
40 | + /** |
|
41 | + * @var \OCP\Files\ObjectStore\IObjectStore $objectStore |
|
42 | + */ |
|
43 | + protected $objectStore; |
|
44 | + /** |
|
45 | + * @var string $id |
|
46 | + */ |
|
47 | + protected $id; |
|
48 | + /** |
|
49 | + * @var \OC\User\User $user |
|
50 | + */ |
|
51 | + protected $user; |
|
52 | + |
|
53 | + private $objectPrefix = 'urn:oid:'; |
|
54 | + |
|
55 | + private $logger; |
|
56 | + |
|
57 | + public function __construct($params) { |
|
58 | + if (isset($params['objectstore']) && $params['objectstore'] instanceof IObjectStore) { |
|
59 | + $this->objectStore = $params['objectstore']; |
|
60 | + } else { |
|
61 | + throw new \Exception('missing IObjectStore instance'); |
|
62 | + } |
|
63 | + if (isset($params['storageid'])) { |
|
64 | + $this->id = 'object::store:' . $params['storageid']; |
|
65 | + } else { |
|
66 | + $this->id = 'object::store:' . $this->objectStore->getStorageId(); |
|
67 | + } |
|
68 | + if (isset($params['objectPrefix'])) { |
|
69 | + $this->objectPrefix = $params['objectPrefix']; |
|
70 | + } |
|
71 | + //initialize cache with root directory in cache |
|
72 | + if (!$this->is_dir('/')) { |
|
73 | + $this->mkdir('/'); |
|
74 | + } |
|
75 | + |
|
76 | + $this->logger = \OC::$server->getLogger(); |
|
77 | + } |
|
78 | + |
|
79 | + public function mkdir($path) { |
|
80 | + $path = $this->normalizePath($path); |
|
81 | + |
|
82 | + if ($this->file_exists($path)) { |
|
83 | + return false; |
|
84 | + } |
|
85 | + |
|
86 | + $mTime = time(); |
|
87 | + $data = [ |
|
88 | + 'mimetype' => 'httpd/unix-directory', |
|
89 | + 'size' => 0, |
|
90 | + 'mtime' => $mTime, |
|
91 | + 'storage_mtime' => $mTime, |
|
92 | + 'permissions' => \OCP\Constants::PERMISSION_ALL, |
|
93 | + ]; |
|
94 | + if ($path === '') { |
|
95 | + //create root on the fly |
|
96 | + $data['etag'] = $this->getETag(''); |
|
97 | + $this->getCache()->put('', $data); |
|
98 | + return true; |
|
99 | + } else { |
|
100 | + // if parent does not exist, create it |
|
101 | + $parent = $this->normalizePath(dirname($path)); |
|
102 | + $parentType = $this->filetype($parent); |
|
103 | + if ($parentType === false) { |
|
104 | + if (!$this->mkdir($parent)) { |
|
105 | + // something went wrong |
|
106 | + return false; |
|
107 | + } |
|
108 | + } elseif ($parentType === 'file') { |
|
109 | + // parent is a file |
|
110 | + return false; |
|
111 | + } |
|
112 | + // finally create the new dir |
|
113 | + $mTime = time(); // update mtime |
|
114 | + $data['mtime'] = $mTime; |
|
115 | + $data['storage_mtime'] = $mTime; |
|
116 | + $data['etag'] = $this->getETag($path); |
|
117 | + $this->getCache()->put($path, $data); |
|
118 | + return true; |
|
119 | + } |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * @param string $path |
|
124 | + * @return string |
|
125 | + */ |
|
126 | + private function normalizePath($path) { |
|
127 | + $path = trim($path, '/'); |
|
128 | + //FIXME why do we sometimes get a path like 'files//username'? |
|
129 | + $path = str_replace('//', '/', $path); |
|
130 | + |
|
131 | + // dirname('/folder') returns '.' but internally (in the cache) we store the root as '' |
|
132 | + if (!$path || $path === '.') { |
|
133 | + $path = ''; |
|
134 | + } |
|
135 | + |
|
136 | + return $path; |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * Object Stores use a NoopScanner because metadata is directly stored in |
|
141 | + * the file cache and cannot really scan the filesystem. The storage passed in is not used anywhere. |
|
142 | + * |
|
143 | + * @param string $path |
|
144 | + * @param \OC\Files\Storage\Storage (optional) the storage to pass to the scanner |
|
145 | + * @return \OC\Files\ObjectStore\NoopScanner |
|
146 | + */ |
|
147 | + public function getScanner($path = '', $storage = null) { |
|
148 | + if (!$storage) { |
|
149 | + $storage = $this; |
|
150 | + } |
|
151 | + if (!isset($this->scanner)) { |
|
152 | + $this->scanner = new NoopScanner($storage); |
|
153 | + } |
|
154 | + return $this->scanner; |
|
155 | + } |
|
156 | + |
|
157 | + public function getId() { |
|
158 | + return $this->id; |
|
159 | + } |
|
160 | + |
|
161 | + public function rmdir($path) { |
|
162 | + $path = $this->normalizePath($path); |
|
163 | + |
|
164 | + if (!$this->is_dir($path)) { |
|
165 | + return false; |
|
166 | + } |
|
167 | + |
|
168 | + if (!$this->rmObjects($path)) { |
|
169 | + return false; |
|
170 | + } |
|
171 | + |
|
172 | + $this->getCache()->remove($path); |
|
173 | + |
|
174 | + return true; |
|
175 | + } |
|
176 | + |
|
177 | + private function rmObjects($path) { |
|
178 | + $children = $this->getCache()->getFolderContents($path); |
|
179 | + foreach ($children as $child) { |
|
180 | + if ($child['mimetype'] === 'httpd/unix-directory') { |
|
181 | + if (!$this->rmObjects($child['path'])) { |
|
182 | + return false; |
|
183 | + } |
|
184 | + } else { |
|
185 | + if (!$this->unlink($child['path'])) { |
|
186 | + return false; |
|
187 | + } |
|
188 | + } |
|
189 | + } |
|
190 | + |
|
191 | + return true; |
|
192 | + } |
|
193 | + |
|
194 | + public function unlink($path) { |
|
195 | + $path = $this->normalizePath($path); |
|
196 | + $stat = $this->stat($path); |
|
197 | + |
|
198 | + if ($stat && isset($stat['fileid'])) { |
|
199 | + if ($stat['mimetype'] === 'httpd/unix-directory') { |
|
200 | + return $this->rmdir($path); |
|
201 | + } |
|
202 | + try { |
|
203 | + $this->objectStore->deleteObject($this->getURN($stat['fileid'])); |
|
204 | + } catch (\Exception $ex) { |
|
205 | + if ($ex->getCode() !== 404) { |
|
206 | + $this->logger->logException($ex, [ |
|
207 | + 'app' => 'objectstore', |
|
208 | + 'message' => 'Could not delete object ' . $this->getURN($stat['fileid']) . ' for ' . $path, |
|
209 | + ]); |
|
210 | + return false; |
|
211 | + } |
|
212 | + //removing from cache is ok as it does not exist in the objectstore anyway |
|
213 | + } |
|
214 | + $this->getCache()->remove($path); |
|
215 | + return true; |
|
216 | + } |
|
217 | + return false; |
|
218 | + } |
|
219 | + |
|
220 | + public function stat($path) { |
|
221 | + $path = $this->normalizePath($path); |
|
222 | + $cacheEntry = $this->getCache()->get($path); |
|
223 | + if ($cacheEntry instanceof CacheEntry) { |
|
224 | + return $cacheEntry->getData(); |
|
225 | + } else { |
|
226 | + return false; |
|
227 | + } |
|
228 | + } |
|
229 | + |
|
230 | + /** |
|
231 | + * Override this method if you need a different unique resource identifier for your object storage implementation. |
|
232 | + * The default implementations just appends the fileId to 'urn:oid:'. Make sure the URN is unique over all users. |
|
233 | + * You may need a mapping table to store your URN if it cannot be generated from the fileid. |
|
234 | + * |
|
235 | + * @param int $fileId the fileid |
|
236 | + * @return null|string the unified resource name used to identify the object |
|
237 | + */ |
|
238 | + public function getURN($fileId) { |
|
239 | + if (is_numeric($fileId)) { |
|
240 | + return $this->objectPrefix . $fileId; |
|
241 | + } |
|
242 | + return null; |
|
243 | + } |
|
244 | + |
|
245 | + public function opendir($path) { |
|
246 | + $path = $this->normalizePath($path); |
|
247 | + |
|
248 | + try { |
|
249 | + $files = []; |
|
250 | + $folderContents = $this->getCache()->getFolderContents($path); |
|
251 | + foreach ($folderContents as $file) { |
|
252 | + $files[] = $file['name']; |
|
253 | + } |
|
254 | + |
|
255 | + return IteratorDirectory::wrap($files); |
|
256 | + } catch (\Exception $e) { |
|
257 | + $this->logger->logException($e); |
|
258 | + return false; |
|
259 | + } |
|
260 | + } |
|
261 | + |
|
262 | + public function filetype($path) { |
|
263 | + $path = $this->normalizePath($path); |
|
264 | + $stat = $this->stat($path); |
|
265 | + if ($stat) { |
|
266 | + if ($stat['mimetype'] === 'httpd/unix-directory') { |
|
267 | + return 'dir'; |
|
268 | + } |
|
269 | + return 'file'; |
|
270 | + } else { |
|
271 | + return false; |
|
272 | + } |
|
273 | + } |
|
274 | + |
|
275 | + public function fopen($path, $mode) { |
|
276 | + $path = $this->normalizePath($path); |
|
277 | + |
|
278 | + if (strrpos($path, '.') !== false) { |
|
279 | + $ext = substr($path, strrpos($path, '.')); |
|
280 | + } else { |
|
281 | + $ext = ''; |
|
282 | + } |
|
283 | + |
|
284 | + switch ($mode) { |
|
285 | + case 'r': |
|
286 | + case 'rb': |
|
287 | + $stat = $this->stat($path); |
|
288 | + if (is_array($stat)) { |
|
289 | + try { |
|
290 | + return $this->objectStore->readObject($this->getURN($stat['fileid'])); |
|
291 | + } catch (NotFoundException $e) { |
|
292 | + $this->logger->logException($e, [ |
|
293 | + 'app' => 'objectstore', |
|
294 | + 'message' => 'Could not get object ' . $this->getURN($stat['fileid']) . ' for file ' . $path, |
|
295 | + ]); |
|
296 | + throw $e; |
|
297 | + } catch (\Exception $ex) { |
|
298 | + $this->logger->logException($ex, [ |
|
299 | + 'app' => 'objectstore', |
|
300 | + 'message' => 'Could not get object ' . $this->getURN($stat['fileid']) . ' for file ' . $path, |
|
301 | + ]); |
|
302 | + return false; |
|
303 | + } |
|
304 | + } else { |
|
305 | + return false; |
|
306 | + } |
|
307 | + // no break |
|
308 | + case 'w': |
|
309 | + case 'wb': |
|
310 | + case 'w+': |
|
311 | + case 'wb+': |
|
312 | + $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext); |
|
313 | + $handle = fopen($tmpFile, $mode); |
|
314 | + return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) { |
|
315 | + $this->writeBack($tmpFile, $path); |
|
316 | + }); |
|
317 | + case 'a': |
|
318 | + case 'ab': |
|
319 | + case 'r+': |
|
320 | + case 'a+': |
|
321 | + case 'x': |
|
322 | + case 'x+': |
|
323 | + case 'c': |
|
324 | + case 'c+': |
|
325 | + $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext); |
|
326 | + if ($this->file_exists($path)) { |
|
327 | + $source = $this->fopen($path, 'r'); |
|
328 | + file_put_contents($tmpFile, $source); |
|
329 | + } |
|
330 | + $handle = fopen($tmpFile, $mode); |
|
331 | + return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) { |
|
332 | + $this->writeBack($tmpFile, $path); |
|
333 | + }); |
|
334 | + } |
|
335 | + return false; |
|
336 | + } |
|
337 | + |
|
338 | + public function file_exists($path) { |
|
339 | + $path = $this->normalizePath($path); |
|
340 | + return (bool)$this->stat($path); |
|
341 | + } |
|
342 | + |
|
343 | + public function rename($source, $target) { |
|
344 | + $source = $this->normalizePath($source); |
|
345 | + $target = $this->normalizePath($target); |
|
346 | + $this->remove($target); |
|
347 | + $this->getCache()->move($source, $target); |
|
348 | + $this->touch(dirname($target)); |
|
349 | + return true; |
|
350 | + } |
|
351 | + |
|
352 | + public function getMimeType($path) { |
|
353 | + $path = $this->normalizePath($path); |
|
354 | + return parent::getMimeType($path); |
|
355 | + } |
|
356 | + |
|
357 | + public function touch($path, $mtime = null) { |
|
358 | + if (is_null($mtime)) { |
|
359 | + $mtime = time(); |
|
360 | + } |
|
361 | + |
|
362 | + $path = $this->normalizePath($path); |
|
363 | + $dirName = dirname($path); |
|
364 | + $parentExists = $this->is_dir($dirName); |
|
365 | + if (!$parentExists) { |
|
366 | + return false; |
|
367 | + } |
|
368 | + |
|
369 | + $stat = $this->stat($path); |
|
370 | + if (is_array($stat)) { |
|
371 | + // update existing mtime in db |
|
372 | + $stat['mtime'] = $mtime; |
|
373 | + $this->getCache()->update($stat['fileid'], $stat); |
|
374 | + } else { |
|
375 | + try { |
|
376 | + //create a empty file, need to have at least on char to make it |
|
377 | + // work with all object storage implementations |
|
378 | + $this->file_put_contents($path, ' '); |
|
379 | + $mimeType = \OC::$server->getMimeTypeDetector()->detectPath($path); |
|
380 | + $stat = [ |
|
381 | + 'etag' => $this->getETag($path), |
|
382 | + 'mimetype' => $mimeType, |
|
383 | + 'size' => 0, |
|
384 | + 'mtime' => $mtime, |
|
385 | + 'storage_mtime' => $mtime, |
|
386 | + 'permissions' => \OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_CREATE, |
|
387 | + ]; |
|
388 | + $this->getCache()->put($path, $stat); |
|
389 | + } catch (\Exception $ex) { |
|
390 | + $this->logger->logException($ex, [ |
|
391 | + 'app' => 'objectstore', |
|
392 | + 'message' => 'Could not create object for ' . $path, |
|
393 | + ]); |
|
394 | + throw $ex; |
|
395 | + } |
|
396 | + } |
|
397 | + return true; |
|
398 | + } |
|
399 | + |
|
400 | + public function writeBack($tmpFile, $path) { |
|
401 | + $size = filesize($tmpFile); |
|
402 | + $this->writeStream($path, fopen($tmpFile, 'r'), $size); |
|
403 | + } |
|
404 | + |
|
405 | + /** |
|
406 | + * external changes are not supported, exclusive access to the object storage is assumed |
|
407 | + * |
|
408 | + * @param string $path |
|
409 | + * @param int $time |
|
410 | + * @return false |
|
411 | + */ |
|
412 | + public function hasUpdated($path, $time) { |
|
413 | + return false; |
|
414 | + } |
|
415 | + |
|
416 | + public function needsPartFile() { |
|
417 | + return false; |
|
418 | + } |
|
419 | + |
|
420 | + public function file_put_contents($path, $data) { |
|
421 | + $handle = $this->fopen($path, 'w+'); |
|
422 | + fwrite($handle, $data); |
|
423 | + fclose($handle); |
|
424 | + return true; |
|
425 | + } |
|
426 | + |
|
427 | + public function writeStream(string $path, $stream, int $size = null): int { |
|
428 | + $stat = $this->stat($path); |
|
429 | + if (empty($stat)) { |
|
430 | + // create new file |
|
431 | + $stat = [ |
|
432 | + 'permissions' => \OCP\Constants::PERMISSION_ALL - \OCP\Constants::PERMISSION_CREATE, |
|
433 | + ]; |
|
434 | + } |
|
435 | + // update stat with new data |
|
436 | + $mTime = time(); |
|
437 | + $stat['size'] = (int)$size; |
|
438 | + $stat['mtime'] = $mTime; |
|
439 | + $stat['storage_mtime'] = $mTime; |
|
440 | + |
|
441 | + $mimetypeDetector = \OC::$server->getMimeTypeDetector(); |
|
442 | + $mimetype = $mimetypeDetector->detectPath($path); |
|
443 | + |
|
444 | + $stat['mimetype'] = $mimetype; |
|
445 | + $stat['etag'] = $this->getETag($path); |
|
446 | + |
|
447 | + $exists = $this->getCache()->inCache($path); |
|
448 | + $uploadPath = $exists ? $path : $path . '.part'; |
|
449 | + $fileId = $this->getCache()->put($uploadPath, $stat); |
|
450 | + $urn = $this->getURN($fileId); |
|
451 | + try { |
|
452 | + //upload to object storage |
|
453 | + if ($size === null) { |
|
454 | + $countStream = CountWrapper::wrap($stream, function ($writtenSize) use ($fileId, &$size) { |
|
455 | + $this->getCache()->update($fileId, [ |
|
456 | + 'size' => $writtenSize |
|
457 | + ]); |
|
458 | + $size = $writtenSize; |
|
459 | + }); |
|
460 | + $this->objectStore->writeObject($urn, $countStream); |
|
461 | + if (is_resource($countStream)) { |
|
462 | + fclose($countStream); |
|
463 | + } |
|
464 | + } else { |
|
465 | + $this->objectStore->writeObject($urn, $stream); |
|
466 | + } |
|
467 | + } catch (\Exception $ex) { |
|
468 | + $this->getCache()->remove($uploadPath); |
|
469 | + $this->logger->logException($ex, [ |
|
470 | + 'app' => 'objectstore', |
|
471 | + 'message' => 'Could not create object ' . $urn . ' for ' . $path, |
|
472 | + ]); |
|
473 | + throw $ex; // make this bubble up |
|
474 | + } |
|
475 | + |
|
476 | + if (!$exists) { |
|
477 | + if ($this->objectStore->objectExists($urn)) { |
|
478 | + $this->getCache()->move($uploadPath, $path); |
|
479 | + } else { |
|
480 | + $this->getCache()->remove($uploadPath); |
|
481 | + throw new \Exception("Object not found after writing (urn: $urn, path: $path)", 404); |
|
482 | + } |
|
483 | + } |
|
484 | + |
|
485 | + return $size; |
|
486 | + } |
|
487 | + |
|
488 | + public function getObjectStore(): IObjectStore { |
|
489 | + return $this->objectStore; |
|
490 | + } |
|
491 | 491 | } |
@@ -30,43 +30,43 @@ |
||
30 | 30 | |
31 | 31 | class RegenerateBirthdayCalendars implements IRepairStep { |
32 | 32 | |
33 | - /** @var IJobList */ |
|
34 | - private $jobList; |
|
33 | + /** @var IJobList */ |
|
34 | + private $jobList; |
|
35 | 35 | |
36 | - /** @var IConfig */ |
|
37 | - private $config; |
|
36 | + /** @var IConfig */ |
|
37 | + private $config; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param IJobList $jobList |
|
41 | - * @param IConfig $config |
|
42 | - */ |
|
43 | - public function __construct(IJobList $jobList, |
|
44 | - IConfig $config) { |
|
45 | - $this->jobList = $jobList; |
|
46 | - $this->config = $config; |
|
47 | - } |
|
39 | + /** |
|
40 | + * @param IJobList $jobList |
|
41 | + * @param IConfig $config |
|
42 | + */ |
|
43 | + public function __construct(IJobList $jobList, |
|
44 | + IConfig $config) { |
|
45 | + $this->jobList = $jobList; |
|
46 | + $this->config = $config; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @return string |
|
51 | - */ |
|
52 | - public function getName() { |
|
53 | - return 'Regenerating birthday calendars to use new icons and fix old birthday events without year'; |
|
54 | - } |
|
49 | + /** |
|
50 | + * @return string |
|
51 | + */ |
|
52 | + public function getName() { |
|
53 | + return 'Regenerating birthday calendars to use new icons and fix old birthday events without year'; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @param IOutput $output |
|
58 | - */ |
|
59 | - public function run(IOutput $output) { |
|
60 | - // only run once |
|
61 | - if ($this->config->getAppValue('dav', 'regeneratedBirthdayCalendarsForYearFix') === 'yes') { |
|
62 | - $output->info('Repair step already executed'); |
|
63 | - return; |
|
64 | - } |
|
56 | + /** |
|
57 | + * @param IOutput $output |
|
58 | + */ |
|
59 | + public function run(IOutput $output) { |
|
60 | + // only run once |
|
61 | + if ($this->config->getAppValue('dav', 'regeneratedBirthdayCalendarsForYearFix') === 'yes') { |
|
62 | + $output->info('Repair step already executed'); |
|
63 | + return; |
|
64 | + } |
|
65 | 65 | |
66 | - $output->info('Adding background jobs to regenerate birthday calendar'); |
|
67 | - $this->jobList->add(RegisterRegenerateBirthdayCalendars::class); |
|
66 | + $output->info('Adding background jobs to regenerate birthday calendar'); |
|
67 | + $this->jobList->add(RegisterRegenerateBirthdayCalendars::class); |
|
68 | 68 | |
69 | - // if all were done, no need to redo the repair during next upgrade |
|
70 | - $this->config->setAppValue('dav', 'regeneratedBirthdayCalendarsForYearFix', 'yes'); |
|
71 | - } |
|
69 | + // if all were done, no need to redo the repair during next upgrade |
|
70 | + $this->config->setAppValue('dav', 'regeneratedBirthdayCalendarsForYearFix', 'yes'); |
|
71 | + } |
|
72 | 72 | } |
@@ -47,59 +47,59 @@ |
||
47 | 47 | */ |
48 | 48 | interface IContainer { |
49 | 49 | |
50 | - /** |
|
51 | - * If a parameter is not registered in the container try to instantiate it |
|
52 | - * by using reflection to find out how to build the class |
|
53 | - * @param string $name the class name to resolve |
|
54 | - * @return \stdClass |
|
55 | - * @since 8.2.0 |
|
56 | - * @throws QueryException if the class could not be found or instantiated |
|
57 | - */ |
|
58 | - public function resolve($name); |
|
50 | + /** |
|
51 | + * If a parameter is not registered in the container try to instantiate it |
|
52 | + * by using reflection to find out how to build the class |
|
53 | + * @param string $name the class name to resolve |
|
54 | + * @return \stdClass |
|
55 | + * @since 8.2.0 |
|
56 | + * @throws QueryException if the class could not be found or instantiated |
|
57 | + */ |
|
58 | + public function resolve($name); |
|
59 | 59 | |
60 | - /** |
|
61 | - * Look up a service for a given name in the container. |
|
62 | - * |
|
63 | - * @param string $name |
|
64 | - * @param bool $autoload Should we try to autoload the service. If we are trying to resolve built in types this makes no sense for example |
|
65 | - * @return mixed |
|
66 | - * @throws QueryException if the query could not be resolved |
|
67 | - * @since 6.0.0 |
|
68 | - */ |
|
69 | - public function query(string $name, bool $autoload = true); |
|
60 | + /** |
|
61 | + * Look up a service for a given name in the container. |
|
62 | + * |
|
63 | + * @param string $name |
|
64 | + * @param bool $autoload Should we try to autoload the service. If we are trying to resolve built in types this makes no sense for example |
|
65 | + * @return mixed |
|
66 | + * @throws QueryException if the query could not be resolved |
|
67 | + * @since 6.0.0 |
|
68 | + */ |
|
69 | + public function query(string $name, bool $autoload = true); |
|
70 | 70 | |
71 | - /** |
|
72 | - * A value is stored in the container with it's corresponding name |
|
73 | - * |
|
74 | - * @param string $name |
|
75 | - * @param mixed $value |
|
76 | - * @return void |
|
77 | - * @since 6.0.0 |
|
78 | - */ |
|
79 | - public function registerParameter($name, $value); |
|
71 | + /** |
|
72 | + * A value is stored in the container with it's corresponding name |
|
73 | + * |
|
74 | + * @param string $name |
|
75 | + * @param mixed $value |
|
76 | + * @return void |
|
77 | + * @since 6.0.0 |
|
78 | + */ |
|
79 | + public function registerParameter($name, $value); |
|
80 | 80 | |
81 | - /** |
|
82 | - * A service is registered in the container where a closure is passed in which will actually |
|
83 | - * create the service on demand. |
|
84 | - * In case the parameter $shared is set to true (the default usage) the once created service will remain in |
|
85 | - * memory and be reused on subsequent calls. |
|
86 | - * In case the parameter is false the service will be recreated on every call. |
|
87 | - * |
|
88 | - * @param string $name |
|
89 | - * @param \Closure $closure |
|
90 | - * @param bool $shared |
|
91 | - * @return void |
|
92 | - * @since 6.0.0 |
|
93 | - */ |
|
94 | - public function registerService($name, Closure $closure, $shared = true); |
|
81 | + /** |
|
82 | + * A service is registered in the container where a closure is passed in which will actually |
|
83 | + * create the service on demand. |
|
84 | + * In case the parameter $shared is set to true (the default usage) the once created service will remain in |
|
85 | + * memory and be reused on subsequent calls. |
|
86 | + * In case the parameter is false the service will be recreated on every call. |
|
87 | + * |
|
88 | + * @param string $name |
|
89 | + * @param \Closure $closure |
|
90 | + * @param bool $shared |
|
91 | + * @return void |
|
92 | + * @since 6.0.0 |
|
93 | + */ |
|
94 | + public function registerService($name, Closure $closure, $shared = true); |
|
95 | 95 | |
96 | - /** |
|
97 | - * Shortcut for returning a service from a service under a different key, |
|
98 | - * e.g. to tell the container to return a class when queried for an |
|
99 | - * interface |
|
100 | - * @param string $alias the alias that should be registered |
|
101 | - * @param string $target the target that should be resolved instead |
|
102 | - * @since 8.2.0 |
|
103 | - */ |
|
104 | - public function registerAlias($alias, $target); |
|
96 | + /** |
|
97 | + * Shortcut for returning a service from a service under a different key, |
|
98 | + * e.g. to tell the container to return a class when queried for an |
|
99 | + * interface |
|
100 | + * @param string $alias the alias that should be registered |
|
101 | + * @param string $target the target that should be resolved instead |
|
102 | + * @since 8.2.0 |
|
103 | + */ |
|
104 | + public function registerAlias($alias, $target); |
|
105 | 105 | } |
@@ -8,7 +8,7 @@ |
||
8 | 8 | <div id="fileSharingSettings" class="section"> |
9 | 9 | <h2 data-anchor-name="federated-cloud"><?php p($l->t('Federated Cloud')); ?></h2> |
10 | 10 | <a target="_blank" rel="noreferrer noopener" class="icon-info svg" |
11 | - title="<?php p($l->t('Open documentation'));?>" |
|
11 | + title="<?php p($l->t('Open documentation')); ?>" |
|
12 | 12 | href="<?php p(link_to_docs('user-sharing-federated')); ?>"></a> |
13 | 13 | <p class="settings-hint"><?php p($l->t('You can share with anyone who uses a Nextcloud server or other Open Cloud Mesh (OCM) compatible servers and services! Just put their Federated Cloud ID in the share dialog. It looks like [email protected]')); ?></p> |
14 | 14 |
@@ -33,68 +33,68 @@ |
||
33 | 33 | |
34 | 34 | class Personal implements ISettings { |
35 | 35 | |
36 | - /** @var FederatedShareProvider */ |
|
37 | - private $federatedShareProvider; |
|
38 | - /** @var IUserSession */ |
|
39 | - private $userSession; |
|
40 | - /** @var IL10N */ |
|
41 | - private $l; |
|
42 | - /** @var \OC_Defaults */ |
|
43 | - private $defaults; |
|
36 | + /** @var FederatedShareProvider */ |
|
37 | + private $federatedShareProvider; |
|
38 | + /** @var IUserSession */ |
|
39 | + private $userSession; |
|
40 | + /** @var IL10N */ |
|
41 | + private $l; |
|
42 | + /** @var \OC_Defaults */ |
|
43 | + private $defaults; |
|
44 | 44 | |
45 | - public function __construct( |
|
46 | - FederatedShareProvider $federatedShareProvider, # |
|
47 | - IUserSession $userSession, |
|
48 | - IL10N $l, |
|
49 | - \OC_Defaults $defaults |
|
50 | - ) { |
|
51 | - $this->federatedShareProvider = $federatedShareProvider; |
|
52 | - $this->userSession = $userSession; |
|
53 | - $this->l = $l; |
|
54 | - $this->defaults = $defaults; |
|
55 | - } |
|
45 | + public function __construct( |
|
46 | + FederatedShareProvider $federatedShareProvider, # |
|
47 | + IUserSession $userSession, |
|
48 | + IL10N $l, |
|
49 | + \OC_Defaults $defaults |
|
50 | + ) { |
|
51 | + $this->federatedShareProvider = $federatedShareProvider; |
|
52 | + $this->userSession = $userSession; |
|
53 | + $this->l = $l; |
|
54 | + $this->defaults = $defaults; |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
59 | - * @since 9.1 |
|
60 | - */ |
|
61 | - public function getForm() { |
|
62 | - $cloudID = $this->userSession->getUser()->getCloudId(); |
|
63 | - $url = 'https://nextcloud.com/sharing#' . $cloudID; |
|
57 | + /** |
|
58 | + * @return TemplateResponse returns the instance with all parameters set, ready to be rendered |
|
59 | + * @since 9.1 |
|
60 | + */ |
|
61 | + public function getForm() { |
|
62 | + $cloudID = $this->userSession->getUser()->getCloudId(); |
|
63 | + $url = 'https://nextcloud.com/sharing#' . $cloudID; |
|
64 | 64 | |
65 | - $parameters = [ |
|
66 | - 'message_with_URL' => $this->l->t('Share with me through my #Nextcloud Federated Cloud ID, see %s', [$url]), |
|
67 | - 'message_without_URL' => $this->l->t('Share with me through my #Nextcloud Federated Cloud ID', [$cloudID]), |
|
68 | - 'logoPath' => $this->defaults->getLogo(), |
|
69 | - 'reference' => $url, |
|
70 | - 'cloudId' => $cloudID, |
|
71 | - 'color' => $this->defaults->getColorPrimary(), |
|
72 | - 'textColor' => "#ffffff", |
|
73 | - ]; |
|
74 | - return new TemplateResponse('federatedfilesharing', 'settings-personal', $parameters, ''); |
|
75 | - } |
|
65 | + $parameters = [ |
|
66 | + 'message_with_URL' => $this->l->t('Share with me through my #Nextcloud Federated Cloud ID, see %s', [$url]), |
|
67 | + 'message_without_URL' => $this->l->t('Share with me through my #Nextcloud Federated Cloud ID', [$cloudID]), |
|
68 | + 'logoPath' => $this->defaults->getLogo(), |
|
69 | + 'reference' => $url, |
|
70 | + 'cloudId' => $cloudID, |
|
71 | + 'color' => $this->defaults->getColorPrimary(), |
|
72 | + 'textColor' => "#ffffff", |
|
73 | + ]; |
|
74 | + return new TemplateResponse('federatedfilesharing', 'settings-personal', $parameters, ''); |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @return string the section ID, e.g. 'sharing' |
|
79 | - * @since 9.1 |
|
80 | - */ |
|
81 | - public function getSection() { |
|
82 | - if ($this->federatedShareProvider->isIncomingServer2serverShareEnabled() || |
|
83 | - $this->federatedShareProvider->isIncomingServer2serverGroupShareEnabled()) { |
|
84 | - return 'sharing'; |
|
85 | - } |
|
86 | - return null; |
|
87 | - } |
|
77 | + /** |
|
78 | + * @return string the section ID, e.g. 'sharing' |
|
79 | + * @since 9.1 |
|
80 | + */ |
|
81 | + public function getSection() { |
|
82 | + if ($this->federatedShareProvider->isIncomingServer2serverShareEnabled() || |
|
83 | + $this->federatedShareProvider->isIncomingServer2serverGroupShareEnabled()) { |
|
84 | + return 'sharing'; |
|
85 | + } |
|
86 | + return null; |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * @return int whether the form should be rather on the top or bottom of |
|
91 | - * the admin section. The forms are arranged in ascending order of the |
|
92 | - * priority values. It is required to return a value between 0 and 100. |
|
93 | - * |
|
94 | - * E.g.: 70 |
|
95 | - * @since 9.1 |
|
96 | - */ |
|
97 | - public function getPriority() { |
|
98 | - return 40; |
|
99 | - } |
|
89 | + /** |
|
90 | + * @return int whether the form should be rather on the top or bottom of |
|
91 | + * the admin section. The forms are arranged in ascending order of the |
|
92 | + * priority values. It is required to return a value between 0 and 100. |
|
93 | + * |
|
94 | + * E.g.: 70 |
|
95 | + * @since 9.1 |
|
96 | + */ |
|
97 | + public function getPriority() { |
|
98 | + return 40; |
|
99 | + } |
|
100 | 100 | } |
@@ -60,7 +60,7 @@ |
||
60 | 60 | */ |
61 | 61 | public function getForm() { |
62 | 62 | $cloudID = $this->userSession->getUser()->getCloudId(); |
63 | - $url = 'https://nextcloud.com/sharing#' . $cloudID; |
|
63 | + $url = 'https://nextcloud.com/sharing#'.$cloudID; |
|
64 | 64 | |
65 | 65 | $parameters = [ |
66 | 66 | 'message_with_URL' => $this->l->t('Share with me through my #Nextcloud Federated Cloud ID, see %s', [$url]), |
@@ -38,70 +38,70 @@ |
||
38 | 38 | |
39 | 39 | class PreviewController extends Controller { |
40 | 40 | |
41 | - /** @var IRootFolder */ |
|
42 | - private $rootFolder; |
|
41 | + /** @var IRootFolder */ |
|
42 | + private $rootFolder; |
|
43 | 43 | |
44 | - /** @var IUserSession */ |
|
45 | - private $userSession; |
|
44 | + /** @var IUserSession */ |
|
45 | + private $userSession; |
|
46 | 46 | |
47 | - /** @var IMimeTypeDetector */ |
|
48 | - private $mimeTypeDetector; |
|
47 | + /** @var IMimeTypeDetector */ |
|
48 | + private $mimeTypeDetector; |
|
49 | 49 | |
50 | - /** @var IVersionManager */ |
|
51 | - private $versionManager; |
|
50 | + /** @var IVersionManager */ |
|
51 | + private $versionManager; |
|
52 | 52 | |
53 | - /** @var IPreview */ |
|
54 | - private $previewManager; |
|
53 | + /** @var IPreview */ |
|
54 | + private $previewManager; |
|
55 | 55 | |
56 | - public function __construct( |
|
57 | - $appName, |
|
58 | - IRequest $request, |
|
59 | - IRootFolder $rootFolder, |
|
60 | - IUserSession $userSession, |
|
61 | - IMimeTypeDetector $mimeTypeDetector, |
|
62 | - IVersionManager $versionManager, |
|
63 | - IPreview $previewManager |
|
64 | - ) { |
|
65 | - parent::__construct($appName, $request); |
|
56 | + public function __construct( |
|
57 | + $appName, |
|
58 | + IRequest $request, |
|
59 | + IRootFolder $rootFolder, |
|
60 | + IUserSession $userSession, |
|
61 | + IMimeTypeDetector $mimeTypeDetector, |
|
62 | + IVersionManager $versionManager, |
|
63 | + IPreview $previewManager |
|
64 | + ) { |
|
65 | + parent::__construct($appName, $request); |
|
66 | 66 | |
67 | - $this->rootFolder = $rootFolder; |
|
68 | - $this->userSession = $userSession; |
|
69 | - $this->mimeTypeDetector = $mimeTypeDetector; |
|
70 | - $this->versionManager = $versionManager; |
|
71 | - $this->previewManager = $previewManager; |
|
72 | - } |
|
67 | + $this->rootFolder = $rootFolder; |
|
68 | + $this->userSession = $userSession; |
|
69 | + $this->mimeTypeDetector = $mimeTypeDetector; |
|
70 | + $this->versionManager = $versionManager; |
|
71 | + $this->previewManager = $previewManager; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @NoAdminRequired |
|
76 | - * @NoCSRFRequired |
|
77 | - * |
|
78 | - * @param string $file |
|
79 | - * @param int $x |
|
80 | - * @param int $y |
|
81 | - * @param string $version |
|
82 | - * @return DataResponse|FileDisplayResponse |
|
83 | - */ |
|
84 | - public function getPreview( |
|
85 | - $file = '', |
|
86 | - $x = 44, |
|
87 | - $y = 44, |
|
88 | - $version = '' |
|
89 | - ) { |
|
90 | - if ($file === '' || $version === '' || $x === 0 || $y === 0) { |
|
91 | - return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
92 | - } |
|
74 | + /** |
|
75 | + * @NoAdminRequired |
|
76 | + * @NoCSRFRequired |
|
77 | + * |
|
78 | + * @param string $file |
|
79 | + * @param int $x |
|
80 | + * @param int $y |
|
81 | + * @param string $version |
|
82 | + * @return DataResponse|FileDisplayResponse |
|
83 | + */ |
|
84 | + public function getPreview( |
|
85 | + $file = '', |
|
86 | + $x = 44, |
|
87 | + $y = 44, |
|
88 | + $version = '' |
|
89 | + ) { |
|
90 | + if ($file === '' || $version === '' || $x === 0 || $y === 0) { |
|
91 | + return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
92 | + } |
|
93 | 93 | |
94 | - try { |
|
95 | - $user = $this->userSession->getUser(); |
|
96 | - $userFolder = $this->rootFolder->getUserFolder($user->getUID()); |
|
97 | - $file = $userFolder->get($file); |
|
98 | - $versionFile = $this->versionManager->getVersionFile($user, $file, $version); |
|
99 | - $preview = $this->previewManager->getPreview($versionFile, $x, $y, true, IPreview::MODE_FILL, $versionFile->getMimetype()); |
|
100 | - return new FileDisplayResponse($preview, Http::STATUS_OK, ['Content-Type' => $preview->getMimeType()]); |
|
101 | - } catch (NotFoundException $e) { |
|
102 | - return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
103 | - } catch (\InvalidArgumentException $e) { |
|
104 | - return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
105 | - } |
|
106 | - } |
|
94 | + try { |
|
95 | + $user = $this->userSession->getUser(); |
|
96 | + $userFolder = $this->rootFolder->getUserFolder($user->getUID()); |
|
97 | + $file = $userFolder->get($file); |
|
98 | + $versionFile = $this->versionManager->getVersionFile($user, $file, $version); |
|
99 | + $preview = $this->previewManager->getPreview($versionFile, $x, $y, true, IPreview::MODE_FILL, $versionFile->getMimetype()); |
|
100 | + return new FileDisplayResponse($preview, Http::STATUS_OK, ['Content-Type' => $preview->getMimeType()]); |
|
101 | + } catch (NotFoundException $e) { |
|
102 | + return new DataResponse([], Http::STATUS_NOT_FOUND); |
|
103 | + } catch (\InvalidArgumentException $e) { |
|
104 | + return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
105 | + } |
|
106 | + } |
|
107 | 107 | } |
@@ -26,88 +26,88 @@ |
||
26 | 26 | use OCP\IUser; |
27 | 27 | |
28 | 28 | class Version implements IVersion { |
29 | - /** @var int */ |
|
30 | - private $timestamp; |
|
31 | - |
|
32 | - /** @var int|string */ |
|
33 | - private $revisionId; |
|
34 | - |
|
35 | - /** @var string */ |
|
36 | - private $name; |
|
37 | - |
|
38 | - /** @var int */ |
|
39 | - private $size; |
|
40 | - |
|
41 | - /** @var string */ |
|
42 | - private $mimetype; |
|
43 | - |
|
44 | - /** @var string */ |
|
45 | - private $path; |
|
46 | - |
|
47 | - /** @var FileInfo */ |
|
48 | - private $sourceFileInfo; |
|
49 | - |
|
50 | - /** @var IVersionBackend */ |
|
51 | - private $backend; |
|
52 | - |
|
53 | - /** @var IUser */ |
|
54 | - private $user; |
|
55 | - |
|
56 | - public function __construct( |
|
57 | - int $timestamp, |
|
58 | - $revisionId, |
|
59 | - string $name, |
|
60 | - int $size, |
|
61 | - string $mimetype, |
|
62 | - string $path, |
|
63 | - FileInfo $sourceFileInfo, |
|
64 | - IVersionBackend $backend, |
|
65 | - IUser $user |
|
66 | - ) { |
|
67 | - $this->timestamp = $timestamp; |
|
68 | - $this->revisionId = $revisionId; |
|
69 | - $this->name = $name; |
|
70 | - $this->size = $size; |
|
71 | - $this->mimetype = $mimetype; |
|
72 | - $this->path = $path; |
|
73 | - $this->sourceFileInfo = $sourceFileInfo; |
|
74 | - $this->backend = $backend; |
|
75 | - $this->user = $user; |
|
76 | - } |
|
77 | - |
|
78 | - public function getBackend(): IVersionBackend { |
|
79 | - return $this->backend; |
|
80 | - } |
|
81 | - |
|
82 | - public function getSourceFile(): FileInfo { |
|
83 | - return $this->sourceFileInfo; |
|
84 | - } |
|
85 | - |
|
86 | - public function getRevisionId() { |
|
87 | - return $this->revisionId; |
|
88 | - } |
|
89 | - |
|
90 | - public function getTimestamp(): int { |
|
91 | - return $this->timestamp; |
|
92 | - } |
|
93 | - |
|
94 | - public function getSize(): int { |
|
95 | - return $this->size; |
|
96 | - } |
|
97 | - |
|
98 | - public function getSourceFileName(): string { |
|
99 | - return $this->name; |
|
100 | - } |
|
101 | - |
|
102 | - public function getMimeType(): string { |
|
103 | - return $this->mimetype; |
|
104 | - } |
|
105 | - |
|
106 | - public function getVersionPath(): string { |
|
107 | - return $this->path; |
|
108 | - } |
|
109 | - |
|
110 | - public function getUser(): IUser { |
|
111 | - return $this->user; |
|
112 | - } |
|
29 | + /** @var int */ |
|
30 | + private $timestamp; |
|
31 | + |
|
32 | + /** @var int|string */ |
|
33 | + private $revisionId; |
|
34 | + |
|
35 | + /** @var string */ |
|
36 | + private $name; |
|
37 | + |
|
38 | + /** @var int */ |
|
39 | + private $size; |
|
40 | + |
|
41 | + /** @var string */ |
|
42 | + private $mimetype; |
|
43 | + |
|
44 | + /** @var string */ |
|
45 | + private $path; |
|
46 | + |
|
47 | + /** @var FileInfo */ |
|
48 | + private $sourceFileInfo; |
|
49 | + |
|
50 | + /** @var IVersionBackend */ |
|
51 | + private $backend; |
|
52 | + |
|
53 | + /** @var IUser */ |
|
54 | + private $user; |
|
55 | + |
|
56 | + public function __construct( |
|
57 | + int $timestamp, |
|
58 | + $revisionId, |
|
59 | + string $name, |
|
60 | + int $size, |
|
61 | + string $mimetype, |
|
62 | + string $path, |
|
63 | + FileInfo $sourceFileInfo, |
|
64 | + IVersionBackend $backend, |
|
65 | + IUser $user |
|
66 | + ) { |
|
67 | + $this->timestamp = $timestamp; |
|
68 | + $this->revisionId = $revisionId; |
|
69 | + $this->name = $name; |
|
70 | + $this->size = $size; |
|
71 | + $this->mimetype = $mimetype; |
|
72 | + $this->path = $path; |
|
73 | + $this->sourceFileInfo = $sourceFileInfo; |
|
74 | + $this->backend = $backend; |
|
75 | + $this->user = $user; |
|
76 | + } |
|
77 | + |
|
78 | + public function getBackend(): IVersionBackend { |
|
79 | + return $this->backend; |
|
80 | + } |
|
81 | + |
|
82 | + public function getSourceFile(): FileInfo { |
|
83 | + return $this->sourceFileInfo; |
|
84 | + } |
|
85 | + |
|
86 | + public function getRevisionId() { |
|
87 | + return $this->revisionId; |
|
88 | + } |
|
89 | + |
|
90 | + public function getTimestamp(): int { |
|
91 | + return $this->timestamp; |
|
92 | + } |
|
93 | + |
|
94 | + public function getSize(): int { |
|
95 | + return $this->size; |
|
96 | + } |
|
97 | + |
|
98 | + public function getSourceFileName(): string { |
|
99 | + return $this->name; |
|
100 | + } |
|
101 | + |
|
102 | + public function getMimeType(): string { |
|
103 | + return $this->mimetype; |
|
104 | + } |
|
105 | + |
|
106 | + public function getVersionPath(): string { |
|
107 | + return $this->path; |
|
108 | + } |
|
109 | + |
|
110 | + public function getUser(): IUser { |
|
111 | + return $this->user; |
|
112 | + } |
|
113 | 113 | } |
@@ -29,71 +29,71 @@ |
||
29 | 29 | * @since 15.0.0 |
30 | 30 | */ |
31 | 31 | interface IVersion { |
32 | - /** |
|
33 | - * @return IVersionBackend |
|
34 | - * @since 15.0.0 |
|
35 | - */ |
|
36 | - public function getBackend(): IVersionBackend; |
|
32 | + /** |
|
33 | + * @return IVersionBackend |
|
34 | + * @since 15.0.0 |
|
35 | + */ |
|
36 | + public function getBackend(): IVersionBackend; |
|
37 | 37 | |
38 | - /** |
|
39 | - * Get the file info of the source file |
|
40 | - * |
|
41 | - * @return FileInfo |
|
42 | - * @since 15.0.0 |
|
43 | - */ |
|
44 | - public function getSourceFile(): FileInfo; |
|
38 | + /** |
|
39 | + * Get the file info of the source file |
|
40 | + * |
|
41 | + * @return FileInfo |
|
42 | + * @since 15.0.0 |
|
43 | + */ |
|
44 | + public function getSourceFile(): FileInfo; |
|
45 | 45 | |
46 | - /** |
|
47 | - * Get the id of the revision for the file |
|
48 | - * |
|
49 | - * @return int|string |
|
50 | - * @since 15.0.0 |
|
51 | - */ |
|
52 | - public function getRevisionId(); |
|
46 | + /** |
|
47 | + * Get the id of the revision for the file |
|
48 | + * |
|
49 | + * @return int|string |
|
50 | + * @since 15.0.0 |
|
51 | + */ |
|
52 | + public function getRevisionId(); |
|
53 | 53 | |
54 | - /** |
|
55 | - * Get the timestamp this version was created |
|
56 | - * |
|
57 | - * @return int |
|
58 | - * @since 15.0.0 |
|
59 | - */ |
|
60 | - public function getTimestamp(): int; |
|
54 | + /** |
|
55 | + * Get the timestamp this version was created |
|
56 | + * |
|
57 | + * @return int |
|
58 | + * @since 15.0.0 |
|
59 | + */ |
|
60 | + public function getTimestamp(): int; |
|
61 | 61 | |
62 | - /** |
|
63 | - * Get the size of this version |
|
64 | - * |
|
65 | - * @return int |
|
66 | - * @since 15.0.0 |
|
67 | - */ |
|
68 | - public function getSize(): int; |
|
62 | + /** |
|
63 | + * Get the size of this version |
|
64 | + * |
|
65 | + * @return int |
|
66 | + * @since 15.0.0 |
|
67 | + */ |
|
68 | + public function getSize(): int; |
|
69 | 69 | |
70 | - /** |
|
71 | - * Get the name of the source file at the time of making this version |
|
72 | - * |
|
73 | - * @return string |
|
74 | - * @since 15.0.0 |
|
75 | - */ |
|
76 | - public function getSourceFileName(): string; |
|
70 | + /** |
|
71 | + * Get the name of the source file at the time of making this version |
|
72 | + * |
|
73 | + * @return string |
|
74 | + * @since 15.0.0 |
|
75 | + */ |
|
76 | + public function getSourceFileName(): string; |
|
77 | 77 | |
78 | - /** |
|
79 | - * Get the mimetype of this version |
|
80 | - * |
|
81 | - * @return string |
|
82 | - * @since 15.0.0 |
|
83 | - */ |
|
84 | - public function getMimeType(): string; |
|
78 | + /** |
|
79 | + * Get the mimetype of this version |
|
80 | + * |
|
81 | + * @return string |
|
82 | + * @since 15.0.0 |
|
83 | + */ |
|
84 | + public function getMimeType(): string; |
|
85 | 85 | |
86 | - /** |
|
87 | - * Get the path of this version |
|
88 | - * |
|
89 | - * @return string |
|
90 | - * @since 15.0.0 |
|
91 | - */ |
|
92 | - public function getVersionPath(): string; |
|
86 | + /** |
|
87 | + * Get the path of this version |
|
88 | + * |
|
89 | + * @return string |
|
90 | + * @since 15.0.0 |
|
91 | + */ |
|
92 | + public function getVersionPath(): string; |
|
93 | 93 | |
94 | - /** |
|
95 | - * @return IUser |
|
96 | - * @since 15.0.0 |
|
97 | - */ |
|
98 | - public function getUser(): IUser; |
|
94 | + /** |
|
95 | + * @return IUser |
|
96 | + * @since 15.0.0 |
|
97 | + */ |
|
98 | + public function getUser(): IUser; |
|
99 | 99 | } |