@@ -32,590 +32,590 @@ |
||
32 | 32 | use OCP\Lock\ILockingProvider; |
33 | 33 | |
34 | 34 | class Wrapper implements \OC\Files\Storage\Storage, ILockingStorage { |
35 | - /** |
|
36 | - * @var \OC\Files\Storage\Storage $storage |
|
37 | - */ |
|
38 | - protected $storage; |
|
39 | - |
|
40 | - public $cache; |
|
41 | - public $scanner; |
|
42 | - public $watcher; |
|
43 | - public $propagator; |
|
44 | - public $updater; |
|
45 | - |
|
46 | - /** |
|
47 | - * @param array $parameters |
|
48 | - */ |
|
49 | - public function __construct($parameters) { |
|
50 | - $this->storage = $parameters['storage']; |
|
51 | - } |
|
52 | - |
|
53 | - /** |
|
54 | - * @return \OC\Files\Storage\Storage |
|
55 | - */ |
|
56 | - public function getWrapperStorage() { |
|
57 | - return $this->storage; |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * Get the identifier for the storage, |
|
62 | - * the returned id should be the same for every storage object that is created with the same parameters |
|
63 | - * and two storage objects with the same id should refer to two storages that display the same files. |
|
64 | - * |
|
65 | - * @return string |
|
66 | - */ |
|
67 | - public function getId() { |
|
68 | - return $this->getWrapperStorage()->getId(); |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * see http://php.net/manual/en/function.mkdir.php |
|
73 | - * |
|
74 | - * @param string $path |
|
75 | - * @return bool |
|
76 | - */ |
|
77 | - public function mkdir($path) { |
|
78 | - return $this->getWrapperStorage()->mkdir($path); |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * see http://php.net/manual/en/function.rmdir.php |
|
83 | - * |
|
84 | - * @param string $path |
|
85 | - * @return bool |
|
86 | - */ |
|
87 | - public function rmdir($path) { |
|
88 | - return $this->getWrapperStorage()->rmdir($path); |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * see http://php.net/manual/en/function.opendir.php |
|
93 | - * |
|
94 | - * @param string $path |
|
95 | - * @return resource |
|
96 | - */ |
|
97 | - public function opendir($path) { |
|
98 | - return $this->getWrapperStorage()->opendir($path); |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * see http://php.net/manual/en/function.is_dir.php |
|
103 | - * |
|
104 | - * @param string $path |
|
105 | - * @return bool |
|
106 | - */ |
|
107 | - public function is_dir($path) { |
|
108 | - return $this->getWrapperStorage()->is_dir($path); |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * see http://php.net/manual/en/function.is_file.php |
|
113 | - * |
|
114 | - * @param string $path |
|
115 | - * @return bool |
|
116 | - */ |
|
117 | - public function is_file($path) { |
|
118 | - return $this->getWrapperStorage()->is_file($path); |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * see http://php.net/manual/en/function.stat.php |
|
123 | - * only the following keys are required in the result: size and mtime |
|
124 | - * |
|
125 | - * @param string $path |
|
126 | - * @return array |
|
127 | - */ |
|
128 | - public function stat($path) { |
|
129 | - return $this->getWrapperStorage()->stat($path); |
|
130 | - } |
|
131 | - |
|
132 | - /** |
|
133 | - * see http://php.net/manual/en/function.filetype.php |
|
134 | - * |
|
135 | - * @param string $path |
|
136 | - * @return bool |
|
137 | - */ |
|
138 | - public function filetype($path) { |
|
139 | - return $this->getWrapperStorage()->filetype($path); |
|
140 | - } |
|
141 | - |
|
142 | - /** |
|
143 | - * see http://php.net/manual/en/function.filesize.php |
|
144 | - * The result for filesize when called on a folder is required to be 0 |
|
145 | - * |
|
146 | - * @param string $path |
|
147 | - * @return int |
|
148 | - */ |
|
149 | - public function filesize($path) { |
|
150 | - return $this->getWrapperStorage()->filesize($path); |
|
151 | - } |
|
152 | - |
|
153 | - /** |
|
154 | - * check if a file can be created in $path |
|
155 | - * |
|
156 | - * @param string $path |
|
157 | - * @return bool |
|
158 | - */ |
|
159 | - public function isCreatable($path) { |
|
160 | - return $this->getWrapperStorage()->isCreatable($path); |
|
161 | - } |
|
162 | - |
|
163 | - /** |
|
164 | - * check if a file can be read |
|
165 | - * |
|
166 | - * @param string $path |
|
167 | - * @return bool |
|
168 | - */ |
|
169 | - public function isReadable($path) { |
|
170 | - return $this->getWrapperStorage()->isReadable($path); |
|
171 | - } |
|
172 | - |
|
173 | - /** |
|
174 | - * check if a file can be written to |
|
175 | - * |
|
176 | - * @param string $path |
|
177 | - * @return bool |
|
178 | - */ |
|
179 | - public function isUpdatable($path) { |
|
180 | - return $this->getWrapperStorage()->isUpdatable($path); |
|
181 | - } |
|
182 | - |
|
183 | - /** |
|
184 | - * check if a file can be deleted |
|
185 | - * |
|
186 | - * @param string $path |
|
187 | - * @return bool |
|
188 | - */ |
|
189 | - public function isDeletable($path) { |
|
190 | - return $this->getWrapperStorage()->isDeletable($path); |
|
191 | - } |
|
192 | - |
|
193 | - /** |
|
194 | - * check if a file can be shared |
|
195 | - * |
|
196 | - * @param string $path |
|
197 | - * @return bool |
|
198 | - */ |
|
199 | - public function isSharable($path) { |
|
200 | - return $this->getWrapperStorage()->isSharable($path); |
|
201 | - } |
|
202 | - |
|
203 | - /** |
|
204 | - * get the full permissions of a path. |
|
205 | - * Should return a combination of the PERMISSION_ constants defined in lib/public/constants.php |
|
206 | - * |
|
207 | - * @param string $path |
|
208 | - * @return int |
|
209 | - */ |
|
210 | - public function getPermissions($path) { |
|
211 | - return $this->getWrapperStorage()->getPermissions($path); |
|
212 | - } |
|
213 | - |
|
214 | - /** |
|
215 | - * see http://php.net/manual/en/function.file_exists.php |
|
216 | - * |
|
217 | - * @param string $path |
|
218 | - * @return bool |
|
219 | - */ |
|
220 | - public function file_exists($path) { |
|
221 | - return $this->getWrapperStorage()->file_exists($path); |
|
222 | - } |
|
223 | - |
|
224 | - /** |
|
225 | - * see http://php.net/manual/en/function.filemtime.php |
|
226 | - * |
|
227 | - * @param string $path |
|
228 | - * @return int |
|
229 | - */ |
|
230 | - public function filemtime($path) { |
|
231 | - return $this->getWrapperStorage()->filemtime($path); |
|
232 | - } |
|
233 | - |
|
234 | - /** |
|
235 | - * see http://php.net/manual/en/function.file_get_contents.php |
|
236 | - * |
|
237 | - * @param string $path |
|
238 | - * @return string |
|
239 | - */ |
|
240 | - public function file_get_contents($path) { |
|
241 | - return $this->getWrapperStorage()->file_get_contents($path); |
|
242 | - } |
|
243 | - |
|
244 | - /** |
|
245 | - * see http://php.net/manual/en/function.file_put_contents.php |
|
246 | - * |
|
247 | - * @param string $path |
|
248 | - * @param string $data |
|
249 | - * @return bool |
|
250 | - */ |
|
251 | - public function file_put_contents($path, $data) { |
|
252 | - return $this->getWrapperStorage()->file_put_contents($path, $data); |
|
253 | - } |
|
254 | - |
|
255 | - /** |
|
256 | - * see http://php.net/manual/en/function.unlink.php |
|
257 | - * |
|
258 | - * @param string $path |
|
259 | - * @return bool |
|
260 | - */ |
|
261 | - public function unlink($path) { |
|
262 | - return $this->getWrapperStorage()->unlink($path); |
|
263 | - } |
|
264 | - |
|
265 | - /** |
|
266 | - * see http://php.net/manual/en/function.rename.php |
|
267 | - * |
|
268 | - * @param string $path1 |
|
269 | - * @param string $path2 |
|
270 | - * @return bool |
|
271 | - */ |
|
272 | - public function rename($path1, $path2) { |
|
273 | - return $this->getWrapperStorage()->rename($path1, $path2); |
|
274 | - } |
|
275 | - |
|
276 | - /** |
|
277 | - * see http://php.net/manual/en/function.copy.php |
|
278 | - * |
|
279 | - * @param string $path1 |
|
280 | - * @param string $path2 |
|
281 | - * @return bool |
|
282 | - */ |
|
283 | - public function copy($path1, $path2) { |
|
284 | - return $this->getWrapperStorage()->copy($path1, $path2); |
|
285 | - } |
|
286 | - |
|
287 | - /** |
|
288 | - * see http://php.net/manual/en/function.fopen.php |
|
289 | - * |
|
290 | - * @param string $path |
|
291 | - * @param string $mode |
|
292 | - * @return resource |
|
293 | - */ |
|
294 | - public function fopen($path, $mode) { |
|
295 | - return $this->getWrapperStorage()->fopen($path, $mode); |
|
296 | - } |
|
297 | - |
|
298 | - /** |
|
299 | - * get the mimetype for a file or folder |
|
300 | - * The mimetype for a folder is required to be "httpd/unix-directory" |
|
301 | - * |
|
302 | - * @param string $path |
|
303 | - * @return string |
|
304 | - */ |
|
305 | - public function getMimeType($path) { |
|
306 | - return $this->getWrapperStorage()->getMimeType($path); |
|
307 | - } |
|
308 | - |
|
309 | - /** |
|
310 | - * see http://php.net/manual/en/function.hash.php |
|
311 | - * |
|
312 | - * @param string $type |
|
313 | - * @param string $path |
|
314 | - * @param bool $raw |
|
315 | - * @return string |
|
316 | - */ |
|
317 | - public function hash($type, $path, $raw = false) { |
|
318 | - return $this->getWrapperStorage()->hash($type, $path, $raw); |
|
319 | - } |
|
320 | - |
|
321 | - /** |
|
322 | - * see http://php.net/manual/en/function.free_space.php |
|
323 | - * |
|
324 | - * @param string $path |
|
325 | - * @return int |
|
326 | - */ |
|
327 | - public function free_space($path) { |
|
328 | - return $this->getWrapperStorage()->free_space($path); |
|
329 | - } |
|
330 | - |
|
331 | - /** |
|
332 | - * search for occurrences of $query in file names |
|
333 | - * |
|
334 | - * @param string $query |
|
335 | - * @return array |
|
336 | - */ |
|
337 | - public function search($query) { |
|
338 | - return $this->getWrapperStorage()->search($query); |
|
339 | - } |
|
340 | - |
|
341 | - /** |
|
342 | - * see http://php.net/manual/en/function.touch.php |
|
343 | - * If the backend does not support the operation, false should be returned |
|
344 | - * |
|
345 | - * @param string $path |
|
346 | - * @param int $mtime |
|
347 | - * @return bool |
|
348 | - */ |
|
349 | - public function touch($path, $mtime = null) { |
|
350 | - return $this->getWrapperStorage()->touch($path, $mtime); |
|
351 | - } |
|
352 | - |
|
353 | - /** |
|
354 | - * get the path to a local version of the file. |
|
355 | - * The local version of the file can be temporary and doesn't have to be persistent across requests |
|
356 | - * |
|
357 | - * @param string $path |
|
358 | - * @return string |
|
359 | - */ |
|
360 | - public function getLocalFile($path) { |
|
361 | - return $this->getWrapperStorage()->getLocalFile($path); |
|
362 | - } |
|
363 | - |
|
364 | - /** |
|
365 | - * check if a file or folder has been updated since $time |
|
366 | - * |
|
367 | - * @param string $path |
|
368 | - * @param int $time |
|
369 | - * @return bool |
|
370 | - * |
|
371 | - * hasUpdated for folders should return at least true if a file inside the folder is add, removed or renamed. |
|
372 | - * returning true for other changes in the folder is optional |
|
373 | - */ |
|
374 | - public function hasUpdated($path, $time) { |
|
375 | - return $this->getWrapperStorage()->hasUpdated($path, $time); |
|
376 | - } |
|
377 | - |
|
378 | - /** |
|
379 | - * get a cache instance for the storage |
|
380 | - * |
|
381 | - * @param string $path |
|
382 | - * @param \OC\Files\Storage\Storage (optional) the storage to pass to the cache |
|
383 | - * @return \OC\Files\Cache\Cache |
|
384 | - */ |
|
385 | - public function getCache($path = '', $storage = null) { |
|
386 | - if (!$storage) { |
|
387 | - $storage = $this; |
|
388 | - } |
|
389 | - return $this->getWrapperStorage()->getCache($path, $storage); |
|
390 | - } |
|
391 | - |
|
392 | - /** |
|
393 | - * get a scanner instance for the storage |
|
394 | - * |
|
395 | - * @param string $path |
|
396 | - * @param \OC\Files\Storage\Storage (optional) the storage to pass to the scanner |
|
397 | - * @return \OC\Files\Cache\Scanner |
|
398 | - */ |
|
399 | - public function getScanner($path = '', $storage = null) { |
|
400 | - if (!$storage) { |
|
401 | - $storage = $this; |
|
402 | - } |
|
403 | - return $this->getWrapperStorage()->getScanner($path, $storage); |
|
404 | - } |
|
405 | - |
|
406 | - |
|
407 | - /** |
|
408 | - * get the user id of the owner of a file or folder |
|
409 | - * |
|
410 | - * @param string $path |
|
411 | - * @return string |
|
412 | - */ |
|
413 | - public function getOwner($path) { |
|
414 | - return $this->getWrapperStorage()->getOwner($path); |
|
415 | - } |
|
416 | - |
|
417 | - /** |
|
418 | - * get a watcher instance for the cache |
|
419 | - * |
|
420 | - * @param string $path |
|
421 | - * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher |
|
422 | - * @return \OC\Files\Cache\Watcher |
|
423 | - */ |
|
424 | - public function getWatcher($path = '', $storage = null) { |
|
425 | - if (!$storage) { |
|
426 | - $storage = $this; |
|
427 | - } |
|
428 | - return $this->getWrapperStorage()->getWatcher($path, $storage); |
|
429 | - } |
|
430 | - |
|
431 | - public function getPropagator($storage = null) { |
|
432 | - if (!$storage) { |
|
433 | - $storage = $this; |
|
434 | - } |
|
435 | - return $this->getWrapperStorage()->getPropagator($storage); |
|
436 | - } |
|
437 | - |
|
438 | - public function getUpdater($storage = null) { |
|
439 | - if (!$storage) { |
|
440 | - $storage = $this; |
|
441 | - } |
|
442 | - return $this->getWrapperStorage()->getUpdater($storage); |
|
443 | - } |
|
444 | - |
|
445 | - /** |
|
446 | - * @return \OC\Files\Cache\Storage |
|
447 | - */ |
|
448 | - public function getStorageCache() { |
|
449 | - return $this->getWrapperStorage()->getStorageCache(); |
|
450 | - } |
|
451 | - |
|
452 | - /** |
|
453 | - * get the ETag for a file or folder |
|
454 | - * |
|
455 | - * @param string $path |
|
456 | - * @return string |
|
457 | - */ |
|
458 | - public function getETag($path) { |
|
459 | - return $this->getWrapperStorage()->getETag($path); |
|
460 | - } |
|
461 | - |
|
462 | - /** |
|
463 | - * Returns true |
|
464 | - * |
|
465 | - * @return true |
|
466 | - */ |
|
467 | - public function test() { |
|
468 | - return $this->getWrapperStorage()->test(); |
|
469 | - } |
|
470 | - |
|
471 | - /** |
|
472 | - * Returns the wrapped storage's value for isLocal() |
|
473 | - * |
|
474 | - * @return bool wrapped storage's isLocal() value |
|
475 | - */ |
|
476 | - public function isLocal() { |
|
477 | - return $this->getWrapperStorage()->isLocal(); |
|
478 | - } |
|
479 | - |
|
480 | - /** |
|
481 | - * Check if the storage is an instance of $class or is a wrapper for a storage that is an instance of $class |
|
482 | - * |
|
483 | - * @param string $class |
|
484 | - * @return bool |
|
485 | - */ |
|
486 | - public function instanceOfStorage($class) { |
|
487 | - if (ltrim($class, '\\') === 'OC\Files\Storage\Shared') { |
|
488 | - // FIXME Temporary fix to keep existing checks working |
|
489 | - $class = '\OCA\Files_Sharing\SharedStorage'; |
|
490 | - } |
|
491 | - return is_a($this, $class) or $this->getWrapperStorage()->instanceOfStorage($class); |
|
492 | - } |
|
493 | - |
|
494 | - /** |
|
495 | - * Pass any methods custom to specific storage implementations to the wrapped storage |
|
496 | - * |
|
497 | - * @param string $method |
|
498 | - * @param array $args |
|
499 | - * @return mixed |
|
500 | - */ |
|
501 | - public function __call($method, $args) { |
|
502 | - return call_user_func_array(array($this->getWrapperStorage(), $method), $args); |
|
503 | - } |
|
504 | - |
|
505 | - /** |
|
506 | - * A custom storage implementation can return an url for direct download of a give file. |
|
507 | - * |
|
508 | - * For now the returned array can hold the parameter url - in future more attributes might follow. |
|
509 | - * |
|
510 | - * @param string $path |
|
511 | - * @return array |
|
512 | - */ |
|
513 | - public function getDirectDownload($path) { |
|
514 | - return $this->getWrapperStorage()->getDirectDownload($path); |
|
515 | - } |
|
516 | - |
|
517 | - /** |
|
518 | - * Get availability of the storage |
|
519 | - * |
|
520 | - * @return array [ available, last_checked ] |
|
521 | - */ |
|
522 | - public function getAvailability() { |
|
523 | - return $this->getWrapperStorage()->getAvailability(); |
|
524 | - } |
|
525 | - |
|
526 | - /** |
|
527 | - * Set availability of the storage |
|
528 | - * |
|
529 | - * @param bool $isAvailable |
|
530 | - */ |
|
531 | - public function setAvailability($isAvailable) { |
|
532 | - $this->getWrapperStorage()->setAvailability($isAvailable); |
|
533 | - } |
|
534 | - |
|
535 | - /** |
|
536 | - * @param string $path the path of the target folder |
|
537 | - * @param string $fileName the name of the file itself |
|
538 | - * @return void |
|
539 | - * @throws InvalidPathException |
|
540 | - */ |
|
541 | - public function verifyPath($path, $fileName) { |
|
542 | - $this->getWrapperStorage()->verifyPath($path, $fileName); |
|
543 | - } |
|
544 | - |
|
545 | - /** |
|
546 | - * @param IStorage $sourceStorage |
|
547 | - * @param string $sourceInternalPath |
|
548 | - * @param string $targetInternalPath |
|
549 | - * @return bool |
|
550 | - */ |
|
551 | - public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { |
|
552 | - if ($sourceStorage === $this) { |
|
553 | - return $this->copy($sourceInternalPath, $targetInternalPath); |
|
554 | - } |
|
555 | - |
|
556 | - return $this->getWrapperStorage()->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); |
|
557 | - } |
|
558 | - |
|
559 | - /** |
|
560 | - * @param IStorage $sourceStorage |
|
561 | - * @param string $sourceInternalPath |
|
562 | - * @param string $targetInternalPath |
|
563 | - * @return bool |
|
564 | - */ |
|
565 | - public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { |
|
566 | - if ($sourceStorage === $this) { |
|
567 | - return $this->rename($sourceInternalPath, $targetInternalPath); |
|
568 | - } |
|
569 | - |
|
570 | - return $this->getWrapperStorage()->moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); |
|
571 | - } |
|
572 | - |
|
573 | - /** |
|
574 | - * @param string $path |
|
575 | - * @return array |
|
576 | - */ |
|
577 | - public function getMetaData($path) { |
|
578 | - return $this->getWrapperStorage()->getMetaData($path); |
|
579 | - } |
|
580 | - |
|
581 | - /** |
|
582 | - * @param string $path |
|
583 | - * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE |
|
584 | - * @param \OCP\Lock\ILockingProvider $provider |
|
585 | - * @throws \OCP\Lock\LockedException |
|
586 | - */ |
|
587 | - public function acquireLock($path, $type, ILockingProvider $provider) { |
|
588 | - if ($this->getWrapperStorage()->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { |
|
589 | - $this->getWrapperStorage()->acquireLock($path, $type, $provider); |
|
590 | - } |
|
591 | - } |
|
592 | - |
|
593 | - /** |
|
594 | - * @param string $path |
|
595 | - * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE |
|
596 | - * @param \OCP\Lock\ILockingProvider $provider |
|
597 | - */ |
|
598 | - public function releaseLock($path, $type, ILockingProvider $provider) { |
|
599 | - if ($this->getWrapperStorage()->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { |
|
600 | - $this->getWrapperStorage()->releaseLock($path, $type, $provider); |
|
601 | - } |
|
602 | - } |
|
603 | - |
|
604 | - /** |
|
605 | - * @param string $path |
|
606 | - * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE |
|
607 | - * @param \OCP\Lock\ILockingProvider $provider |
|
608 | - */ |
|
609 | - public function changeLock($path, $type, ILockingProvider $provider) { |
|
610 | - if ($this->getWrapperStorage()->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { |
|
611 | - $this->getWrapperStorage()->changeLock($path, $type, $provider); |
|
612 | - } |
|
613 | - } |
|
614 | - |
|
615 | - /** |
|
616 | - * @return bool |
|
617 | - */ |
|
618 | - public function needsPartFile() { |
|
619 | - return $this->getWrapperStorage()->needsPartFile(); |
|
620 | - } |
|
35 | + /** |
|
36 | + * @var \OC\Files\Storage\Storage $storage |
|
37 | + */ |
|
38 | + protected $storage; |
|
39 | + |
|
40 | + public $cache; |
|
41 | + public $scanner; |
|
42 | + public $watcher; |
|
43 | + public $propagator; |
|
44 | + public $updater; |
|
45 | + |
|
46 | + /** |
|
47 | + * @param array $parameters |
|
48 | + */ |
|
49 | + public function __construct($parameters) { |
|
50 | + $this->storage = $parameters['storage']; |
|
51 | + } |
|
52 | + |
|
53 | + /** |
|
54 | + * @return \OC\Files\Storage\Storage |
|
55 | + */ |
|
56 | + public function getWrapperStorage() { |
|
57 | + return $this->storage; |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * Get the identifier for the storage, |
|
62 | + * the returned id should be the same for every storage object that is created with the same parameters |
|
63 | + * and two storage objects with the same id should refer to two storages that display the same files. |
|
64 | + * |
|
65 | + * @return string |
|
66 | + */ |
|
67 | + public function getId() { |
|
68 | + return $this->getWrapperStorage()->getId(); |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * see http://php.net/manual/en/function.mkdir.php |
|
73 | + * |
|
74 | + * @param string $path |
|
75 | + * @return bool |
|
76 | + */ |
|
77 | + public function mkdir($path) { |
|
78 | + return $this->getWrapperStorage()->mkdir($path); |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * see http://php.net/manual/en/function.rmdir.php |
|
83 | + * |
|
84 | + * @param string $path |
|
85 | + * @return bool |
|
86 | + */ |
|
87 | + public function rmdir($path) { |
|
88 | + return $this->getWrapperStorage()->rmdir($path); |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * see http://php.net/manual/en/function.opendir.php |
|
93 | + * |
|
94 | + * @param string $path |
|
95 | + * @return resource |
|
96 | + */ |
|
97 | + public function opendir($path) { |
|
98 | + return $this->getWrapperStorage()->opendir($path); |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * see http://php.net/manual/en/function.is_dir.php |
|
103 | + * |
|
104 | + * @param string $path |
|
105 | + * @return bool |
|
106 | + */ |
|
107 | + public function is_dir($path) { |
|
108 | + return $this->getWrapperStorage()->is_dir($path); |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * see http://php.net/manual/en/function.is_file.php |
|
113 | + * |
|
114 | + * @param string $path |
|
115 | + * @return bool |
|
116 | + */ |
|
117 | + public function is_file($path) { |
|
118 | + return $this->getWrapperStorage()->is_file($path); |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * see http://php.net/manual/en/function.stat.php |
|
123 | + * only the following keys are required in the result: size and mtime |
|
124 | + * |
|
125 | + * @param string $path |
|
126 | + * @return array |
|
127 | + */ |
|
128 | + public function stat($path) { |
|
129 | + return $this->getWrapperStorage()->stat($path); |
|
130 | + } |
|
131 | + |
|
132 | + /** |
|
133 | + * see http://php.net/manual/en/function.filetype.php |
|
134 | + * |
|
135 | + * @param string $path |
|
136 | + * @return bool |
|
137 | + */ |
|
138 | + public function filetype($path) { |
|
139 | + return $this->getWrapperStorage()->filetype($path); |
|
140 | + } |
|
141 | + |
|
142 | + /** |
|
143 | + * see http://php.net/manual/en/function.filesize.php |
|
144 | + * The result for filesize when called on a folder is required to be 0 |
|
145 | + * |
|
146 | + * @param string $path |
|
147 | + * @return int |
|
148 | + */ |
|
149 | + public function filesize($path) { |
|
150 | + return $this->getWrapperStorage()->filesize($path); |
|
151 | + } |
|
152 | + |
|
153 | + /** |
|
154 | + * check if a file can be created in $path |
|
155 | + * |
|
156 | + * @param string $path |
|
157 | + * @return bool |
|
158 | + */ |
|
159 | + public function isCreatable($path) { |
|
160 | + return $this->getWrapperStorage()->isCreatable($path); |
|
161 | + } |
|
162 | + |
|
163 | + /** |
|
164 | + * check if a file can be read |
|
165 | + * |
|
166 | + * @param string $path |
|
167 | + * @return bool |
|
168 | + */ |
|
169 | + public function isReadable($path) { |
|
170 | + return $this->getWrapperStorage()->isReadable($path); |
|
171 | + } |
|
172 | + |
|
173 | + /** |
|
174 | + * check if a file can be written to |
|
175 | + * |
|
176 | + * @param string $path |
|
177 | + * @return bool |
|
178 | + */ |
|
179 | + public function isUpdatable($path) { |
|
180 | + return $this->getWrapperStorage()->isUpdatable($path); |
|
181 | + } |
|
182 | + |
|
183 | + /** |
|
184 | + * check if a file can be deleted |
|
185 | + * |
|
186 | + * @param string $path |
|
187 | + * @return bool |
|
188 | + */ |
|
189 | + public function isDeletable($path) { |
|
190 | + return $this->getWrapperStorage()->isDeletable($path); |
|
191 | + } |
|
192 | + |
|
193 | + /** |
|
194 | + * check if a file can be shared |
|
195 | + * |
|
196 | + * @param string $path |
|
197 | + * @return bool |
|
198 | + */ |
|
199 | + public function isSharable($path) { |
|
200 | + return $this->getWrapperStorage()->isSharable($path); |
|
201 | + } |
|
202 | + |
|
203 | + /** |
|
204 | + * get the full permissions of a path. |
|
205 | + * Should return a combination of the PERMISSION_ constants defined in lib/public/constants.php |
|
206 | + * |
|
207 | + * @param string $path |
|
208 | + * @return int |
|
209 | + */ |
|
210 | + public function getPermissions($path) { |
|
211 | + return $this->getWrapperStorage()->getPermissions($path); |
|
212 | + } |
|
213 | + |
|
214 | + /** |
|
215 | + * see http://php.net/manual/en/function.file_exists.php |
|
216 | + * |
|
217 | + * @param string $path |
|
218 | + * @return bool |
|
219 | + */ |
|
220 | + public function file_exists($path) { |
|
221 | + return $this->getWrapperStorage()->file_exists($path); |
|
222 | + } |
|
223 | + |
|
224 | + /** |
|
225 | + * see http://php.net/manual/en/function.filemtime.php |
|
226 | + * |
|
227 | + * @param string $path |
|
228 | + * @return int |
|
229 | + */ |
|
230 | + public function filemtime($path) { |
|
231 | + return $this->getWrapperStorage()->filemtime($path); |
|
232 | + } |
|
233 | + |
|
234 | + /** |
|
235 | + * see http://php.net/manual/en/function.file_get_contents.php |
|
236 | + * |
|
237 | + * @param string $path |
|
238 | + * @return string |
|
239 | + */ |
|
240 | + public function file_get_contents($path) { |
|
241 | + return $this->getWrapperStorage()->file_get_contents($path); |
|
242 | + } |
|
243 | + |
|
244 | + /** |
|
245 | + * see http://php.net/manual/en/function.file_put_contents.php |
|
246 | + * |
|
247 | + * @param string $path |
|
248 | + * @param string $data |
|
249 | + * @return bool |
|
250 | + */ |
|
251 | + public function file_put_contents($path, $data) { |
|
252 | + return $this->getWrapperStorage()->file_put_contents($path, $data); |
|
253 | + } |
|
254 | + |
|
255 | + /** |
|
256 | + * see http://php.net/manual/en/function.unlink.php |
|
257 | + * |
|
258 | + * @param string $path |
|
259 | + * @return bool |
|
260 | + */ |
|
261 | + public function unlink($path) { |
|
262 | + return $this->getWrapperStorage()->unlink($path); |
|
263 | + } |
|
264 | + |
|
265 | + /** |
|
266 | + * see http://php.net/manual/en/function.rename.php |
|
267 | + * |
|
268 | + * @param string $path1 |
|
269 | + * @param string $path2 |
|
270 | + * @return bool |
|
271 | + */ |
|
272 | + public function rename($path1, $path2) { |
|
273 | + return $this->getWrapperStorage()->rename($path1, $path2); |
|
274 | + } |
|
275 | + |
|
276 | + /** |
|
277 | + * see http://php.net/manual/en/function.copy.php |
|
278 | + * |
|
279 | + * @param string $path1 |
|
280 | + * @param string $path2 |
|
281 | + * @return bool |
|
282 | + */ |
|
283 | + public function copy($path1, $path2) { |
|
284 | + return $this->getWrapperStorage()->copy($path1, $path2); |
|
285 | + } |
|
286 | + |
|
287 | + /** |
|
288 | + * see http://php.net/manual/en/function.fopen.php |
|
289 | + * |
|
290 | + * @param string $path |
|
291 | + * @param string $mode |
|
292 | + * @return resource |
|
293 | + */ |
|
294 | + public function fopen($path, $mode) { |
|
295 | + return $this->getWrapperStorage()->fopen($path, $mode); |
|
296 | + } |
|
297 | + |
|
298 | + /** |
|
299 | + * get the mimetype for a file or folder |
|
300 | + * The mimetype for a folder is required to be "httpd/unix-directory" |
|
301 | + * |
|
302 | + * @param string $path |
|
303 | + * @return string |
|
304 | + */ |
|
305 | + public function getMimeType($path) { |
|
306 | + return $this->getWrapperStorage()->getMimeType($path); |
|
307 | + } |
|
308 | + |
|
309 | + /** |
|
310 | + * see http://php.net/manual/en/function.hash.php |
|
311 | + * |
|
312 | + * @param string $type |
|
313 | + * @param string $path |
|
314 | + * @param bool $raw |
|
315 | + * @return string |
|
316 | + */ |
|
317 | + public function hash($type, $path, $raw = false) { |
|
318 | + return $this->getWrapperStorage()->hash($type, $path, $raw); |
|
319 | + } |
|
320 | + |
|
321 | + /** |
|
322 | + * see http://php.net/manual/en/function.free_space.php |
|
323 | + * |
|
324 | + * @param string $path |
|
325 | + * @return int |
|
326 | + */ |
|
327 | + public function free_space($path) { |
|
328 | + return $this->getWrapperStorage()->free_space($path); |
|
329 | + } |
|
330 | + |
|
331 | + /** |
|
332 | + * search for occurrences of $query in file names |
|
333 | + * |
|
334 | + * @param string $query |
|
335 | + * @return array |
|
336 | + */ |
|
337 | + public function search($query) { |
|
338 | + return $this->getWrapperStorage()->search($query); |
|
339 | + } |
|
340 | + |
|
341 | + /** |
|
342 | + * see http://php.net/manual/en/function.touch.php |
|
343 | + * If the backend does not support the operation, false should be returned |
|
344 | + * |
|
345 | + * @param string $path |
|
346 | + * @param int $mtime |
|
347 | + * @return bool |
|
348 | + */ |
|
349 | + public function touch($path, $mtime = null) { |
|
350 | + return $this->getWrapperStorage()->touch($path, $mtime); |
|
351 | + } |
|
352 | + |
|
353 | + /** |
|
354 | + * get the path to a local version of the file. |
|
355 | + * The local version of the file can be temporary and doesn't have to be persistent across requests |
|
356 | + * |
|
357 | + * @param string $path |
|
358 | + * @return string |
|
359 | + */ |
|
360 | + public function getLocalFile($path) { |
|
361 | + return $this->getWrapperStorage()->getLocalFile($path); |
|
362 | + } |
|
363 | + |
|
364 | + /** |
|
365 | + * check if a file or folder has been updated since $time |
|
366 | + * |
|
367 | + * @param string $path |
|
368 | + * @param int $time |
|
369 | + * @return bool |
|
370 | + * |
|
371 | + * hasUpdated for folders should return at least true if a file inside the folder is add, removed or renamed. |
|
372 | + * returning true for other changes in the folder is optional |
|
373 | + */ |
|
374 | + public function hasUpdated($path, $time) { |
|
375 | + return $this->getWrapperStorage()->hasUpdated($path, $time); |
|
376 | + } |
|
377 | + |
|
378 | + /** |
|
379 | + * get a cache instance for the storage |
|
380 | + * |
|
381 | + * @param string $path |
|
382 | + * @param \OC\Files\Storage\Storage (optional) the storage to pass to the cache |
|
383 | + * @return \OC\Files\Cache\Cache |
|
384 | + */ |
|
385 | + public function getCache($path = '', $storage = null) { |
|
386 | + if (!$storage) { |
|
387 | + $storage = $this; |
|
388 | + } |
|
389 | + return $this->getWrapperStorage()->getCache($path, $storage); |
|
390 | + } |
|
391 | + |
|
392 | + /** |
|
393 | + * get a scanner instance for the storage |
|
394 | + * |
|
395 | + * @param string $path |
|
396 | + * @param \OC\Files\Storage\Storage (optional) the storage to pass to the scanner |
|
397 | + * @return \OC\Files\Cache\Scanner |
|
398 | + */ |
|
399 | + public function getScanner($path = '', $storage = null) { |
|
400 | + if (!$storage) { |
|
401 | + $storage = $this; |
|
402 | + } |
|
403 | + return $this->getWrapperStorage()->getScanner($path, $storage); |
|
404 | + } |
|
405 | + |
|
406 | + |
|
407 | + /** |
|
408 | + * get the user id of the owner of a file or folder |
|
409 | + * |
|
410 | + * @param string $path |
|
411 | + * @return string |
|
412 | + */ |
|
413 | + public function getOwner($path) { |
|
414 | + return $this->getWrapperStorage()->getOwner($path); |
|
415 | + } |
|
416 | + |
|
417 | + /** |
|
418 | + * get a watcher instance for the cache |
|
419 | + * |
|
420 | + * @param string $path |
|
421 | + * @param \OC\Files\Storage\Storage (optional) the storage to pass to the watcher |
|
422 | + * @return \OC\Files\Cache\Watcher |
|
423 | + */ |
|
424 | + public function getWatcher($path = '', $storage = null) { |
|
425 | + if (!$storage) { |
|
426 | + $storage = $this; |
|
427 | + } |
|
428 | + return $this->getWrapperStorage()->getWatcher($path, $storage); |
|
429 | + } |
|
430 | + |
|
431 | + public function getPropagator($storage = null) { |
|
432 | + if (!$storage) { |
|
433 | + $storage = $this; |
|
434 | + } |
|
435 | + return $this->getWrapperStorage()->getPropagator($storage); |
|
436 | + } |
|
437 | + |
|
438 | + public function getUpdater($storage = null) { |
|
439 | + if (!$storage) { |
|
440 | + $storage = $this; |
|
441 | + } |
|
442 | + return $this->getWrapperStorage()->getUpdater($storage); |
|
443 | + } |
|
444 | + |
|
445 | + /** |
|
446 | + * @return \OC\Files\Cache\Storage |
|
447 | + */ |
|
448 | + public function getStorageCache() { |
|
449 | + return $this->getWrapperStorage()->getStorageCache(); |
|
450 | + } |
|
451 | + |
|
452 | + /** |
|
453 | + * get the ETag for a file or folder |
|
454 | + * |
|
455 | + * @param string $path |
|
456 | + * @return string |
|
457 | + */ |
|
458 | + public function getETag($path) { |
|
459 | + return $this->getWrapperStorage()->getETag($path); |
|
460 | + } |
|
461 | + |
|
462 | + /** |
|
463 | + * Returns true |
|
464 | + * |
|
465 | + * @return true |
|
466 | + */ |
|
467 | + public function test() { |
|
468 | + return $this->getWrapperStorage()->test(); |
|
469 | + } |
|
470 | + |
|
471 | + /** |
|
472 | + * Returns the wrapped storage's value for isLocal() |
|
473 | + * |
|
474 | + * @return bool wrapped storage's isLocal() value |
|
475 | + */ |
|
476 | + public function isLocal() { |
|
477 | + return $this->getWrapperStorage()->isLocal(); |
|
478 | + } |
|
479 | + |
|
480 | + /** |
|
481 | + * Check if the storage is an instance of $class or is a wrapper for a storage that is an instance of $class |
|
482 | + * |
|
483 | + * @param string $class |
|
484 | + * @return bool |
|
485 | + */ |
|
486 | + public function instanceOfStorage($class) { |
|
487 | + if (ltrim($class, '\\') === 'OC\Files\Storage\Shared') { |
|
488 | + // FIXME Temporary fix to keep existing checks working |
|
489 | + $class = '\OCA\Files_Sharing\SharedStorage'; |
|
490 | + } |
|
491 | + return is_a($this, $class) or $this->getWrapperStorage()->instanceOfStorage($class); |
|
492 | + } |
|
493 | + |
|
494 | + /** |
|
495 | + * Pass any methods custom to specific storage implementations to the wrapped storage |
|
496 | + * |
|
497 | + * @param string $method |
|
498 | + * @param array $args |
|
499 | + * @return mixed |
|
500 | + */ |
|
501 | + public function __call($method, $args) { |
|
502 | + return call_user_func_array(array($this->getWrapperStorage(), $method), $args); |
|
503 | + } |
|
504 | + |
|
505 | + /** |
|
506 | + * A custom storage implementation can return an url for direct download of a give file. |
|
507 | + * |
|
508 | + * For now the returned array can hold the parameter url - in future more attributes might follow. |
|
509 | + * |
|
510 | + * @param string $path |
|
511 | + * @return array |
|
512 | + */ |
|
513 | + public function getDirectDownload($path) { |
|
514 | + return $this->getWrapperStorage()->getDirectDownload($path); |
|
515 | + } |
|
516 | + |
|
517 | + /** |
|
518 | + * Get availability of the storage |
|
519 | + * |
|
520 | + * @return array [ available, last_checked ] |
|
521 | + */ |
|
522 | + public function getAvailability() { |
|
523 | + return $this->getWrapperStorage()->getAvailability(); |
|
524 | + } |
|
525 | + |
|
526 | + /** |
|
527 | + * Set availability of the storage |
|
528 | + * |
|
529 | + * @param bool $isAvailable |
|
530 | + */ |
|
531 | + public function setAvailability($isAvailable) { |
|
532 | + $this->getWrapperStorage()->setAvailability($isAvailable); |
|
533 | + } |
|
534 | + |
|
535 | + /** |
|
536 | + * @param string $path the path of the target folder |
|
537 | + * @param string $fileName the name of the file itself |
|
538 | + * @return void |
|
539 | + * @throws InvalidPathException |
|
540 | + */ |
|
541 | + public function verifyPath($path, $fileName) { |
|
542 | + $this->getWrapperStorage()->verifyPath($path, $fileName); |
|
543 | + } |
|
544 | + |
|
545 | + /** |
|
546 | + * @param IStorage $sourceStorage |
|
547 | + * @param string $sourceInternalPath |
|
548 | + * @param string $targetInternalPath |
|
549 | + * @return bool |
|
550 | + */ |
|
551 | + public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { |
|
552 | + if ($sourceStorage === $this) { |
|
553 | + return $this->copy($sourceInternalPath, $targetInternalPath); |
|
554 | + } |
|
555 | + |
|
556 | + return $this->getWrapperStorage()->copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); |
|
557 | + } |
|
558 | + |
|
559 | + /** |
|
560 | + * @param IStorage $sourceStorage |
|
561 | + * @param string $sourceInternalPath |
|
562 | + * @param string $targetInternalPath |
|
563 | + * @return bool |
|
564 | + */ |
|
565 | + public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { |
|
566 | + if ($sourceStorage === $this) { |
|
567 | + return $this->rename($sourceInternalPath, $targetInternalPath); |
|
568 | + } |
|
569 | + |
|
570 | + return $this->getWrapperStorage()->moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); |
|
571 | + } |
|
572 | + |
|
573 | + /** |
|
574 | + * @param string $path |
|
575 | + * @return array |
|
576 | + */ |
|
577 | + public function getMetaData($path) { |
|
578 | + return $this->getWrapperStorage()->getMetaData($path); |
|
579 | + } |
|
580 | + |
|
581 | + /** |
|
582 | + * @param string $path |
|
583 | + * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE |
|
584 | + * @param \OCP\Lock\ILockingProvider $provider |
|
585 | + * @throws \OCP\Lock\LockedException |
|
586 | + */ |
|
587 | + public function acquireLock($path, $type, ILockingProvider $provider) { |
|
588 | + if ($this->getWrapperStorage()->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { |
|
589 | + $this->getWrapperStorage()->acquireLock($path, $type, $provider); |
|
590 | + } |
|
591 | + } |
|
592 | + |
|
593 | + /** |
|
594 | + * @param string $path |
|
595 | + * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE |
|
596 | + * @param \OCP\Lock\ILockingProvider $provider |
|
597 | + */ |
|
598 | + public function releaseLock($path, $type, ILockingProvider $provider) { |
|
599 | + if ($this->getWrapperStorage()->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { |
|
600 | + $this->getWrapperStorage()->releaseLock($path, $type, $provider); |
|
601 | + } |
|
602 | + } |
|
603 | + |
|
604 | + /** |
|
605 | + * @param string $path |
|
606 | + * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE |
|
607 | + * @param \OCP\Lock\ILockingProvider $provider |
|
608 | + */ |
|
609 | + public function changeLock($path, $type, ILockingProvider $provider) { |
|
610 | + if ($this->getWrapperStorage()->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) { |
|
611 | + $this->getWrapperStorage()->changeLock($path, $type, $provider); |
|
612 | + } |
|
613 | + } |
|
614 | + |
|
615 | + /** |
|
616 | + * @return bool |
|
617 | + */ |
|
618 | + public function needsPartFile() { |
|
619 | + return $this->getWrapperStorage()->needsPartFile(); |
|
620 | + } |
|
621 | 621 | } |
@@ -30,439 +30,439 @@ |
||
30 | 30 | * Throws a StorageNotAvailableException for storages with known failures |
31 | 31 | */ |
32 | 32 | class Availability extends Wrapper { |
33 | - const RECHECK_TTL_SEC = 600; // 10 minutes |
|
34 | - |
|
35 | - public static function shouldRecheck($availability) { |
|
36 | - if (!$availability['available']) { |
|
37 | - // trigger a recheck if TTL reached |
|
38 | - if ((time() - $availability['last_checked']) > self::RECHECK_TTL_SEC) { |
|
39 | - return true; |
|
40 | - } |
|
41 | - } |
|
42 | - return false; |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * Only called if availability === false |
|
47 | - * |
|
48 | - * @return bool |
|
49 | - */ |
|
50 | - private function updateAvailability() { |
|
51 | - // reset availability to false so that multiple requests don't recheck concurrently |
|
52 | - $this->setAvailability(false); |
|
53 | - try { |
|
54 | - $result = $this->test(); |
|
55 | - } catch (\Exception $e) { |
|
56 | - $result = false; |
|
57 | - } |
|
58 | - $this->setAvailability($result); |
|
59 | - return $result; |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * @return bool |
|
64 | - */ |
|
65 | - private function isAvailable() { |
|
66 | - $availability = $this->getAvailability(); |
|
67 | - if (self::shouldRecheck($availability)) { |
|
68 | - return $this->updateAvailability(); |
|
69 | - } |
|
70 | - return $availability['available']; |
|
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * @throws \OCP\Files\StorageNotAvailableException |
|
75 | - */ |
|
76 | - private function checkAvailability() { |
|
77 | - if (!$this->isAvailable()) { |
|
78 | - throw new \OCP\Files\StorageNotAvailableException(); |
|
79 | - } |
|
80 | - } |
|
81 | - |
|
82 | - /** {@inheritdoc} */ |
|
83 | - public function mkdir($path) { |
|
84 | - $this->checkAvailability(); |
|
85 | - try { |
|
86 | - return parent::mkdir($path); |
|
87 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
88 | - $this->setAvailability(false); |
|
89 | - throw $e; |
|
90 | - } |
|
91 | - } |
|
92 | - |
|
93 | - /** {@inheritdoc} */ |
|
94 | - public function rmdir($path) { |
|
95 | - $this->checkAvailability(); |
|
96 | - try { |
|
97 | - return parent::rmdir($path); |
|
98 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
99 | - $this->setAvailability(false); |
|
100 | - throw $e; |
|
101 | - } |
|
102 | - } |
|
103 | - |
|
104 | - /** {@inheritdoc} */ |
|
105 | - public function opendir($path) { |
|
106 | - $this->checkAvailability(); |
|
107 | - try { |
|
108 | - return parent::opendir($path); |
|
109 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
110 | - $this->setAvailability(false); |
|
111 | - throw $e; |
|
112 | - } |
|
113 | - } |
|
114 | - |
|
115 | - /** {@inheritdoc} */ |
|
116 | - public function is_dir($path) { |
|
117 | - $this->checkAvailability(); |
|
118 | - try { |
|
119 | - return parent::is_dir($path); |
|
120 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
121 | - $this->setAvailability(false); |
|
122 | - throw $e; |
|
123 | - } |
|
124 | - } |
|
125 | - |
|
126 | - /** {@inheritdoc} */ |
|
127 | - public function is_file($path) { |
|
128 | - $this->checkAvailability(); |
|
129 | - try { |
|
130 | - return parent::is_file($path); |
|
131 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
132 | - $this->setAvailability(false); |
|
133 | - throw $e; |
|
134 | - } |
|
135 | - } |
|
136 | - |
|
137 | - /** {@inheritdoc} */ |
|
138 | - public function stat($path) { |
|
139 | - $this->checkAvailability(); |
|
140 | - try { |
|
141 | - return parent::stat($path); |
|
142 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
143 | - $this->setAvailability(false); |
|
144 | - throw $e; |
|
145 | - } |
|
146 | - } |
|
147 | - |
|
148 | - /** {@inheritdoc} */ |
|
149 | - public function filetype($path) { |
|
150 | - $this->checkAvailability(); |
|
151 | - try { |
|
152 | - return parent::filetype($path); |
|
153 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
154 | - $this->setAvailability(false); |
|
155 | - throw $e; |
|
156 | - } |
|
157 | - } |
|
158 | - |
|
159 | - /** {@inheritdoc} */ |
|
160 | - public function filesize($path) { |
|
161 | - $this->checkAvailability(); |
|
162 | - try { |
|
163 | - return parent::filesize($path); |
|
164 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
165 | - $this->setAvailability(false); |
|
166 | - throw $e; |
|
167 | - } |
|
168 | - } |
|
169 | - |
|
170 | - /** {@inheritdoc} */ |
|
171 | - public function isCreatable($path) { |
|
172 | - $this->checkAvailability(); |
|
173 | - try { |
|
174 | - return parent::isCreatable($path); |
|
175 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
176 | - $this->setAvailability(false); |
|
177 | - throw $e; |
|
178 | - } |
|
179 | - } |
|
180 | - |
|
181 | - /** {@inheritdoc} */ |
|
182 | - public function isReadable($path) { |
|
183 | - $this->checkAvailability(); |
|
184 | - try { |
|
185 | - return parent::isReadable($path); |
|
186 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
187 | - $this->setAvailability(false); |
|
188 | - throw $e; |
|
189 | - } |
|
190 | - } |
|
191 | - |
|
192 | - /** {@inheritdoc} */ |
|
193 | - public function isUpdatable($path) { |
|
194 | - $this->checkAvailability(); |
|
195 | - try { |
|
196 | - return parent::isUpdatable($path); |
|
197 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
198 | - $this->setAvailability(false); |
|
199 | - throw $e; |
|
200 | - } |
|
201 | - } |
|
202 | - |
|
203 | - /** {@inheritdoc} */ |
|
204 | - public function isDeletable($path) { |
|
205 | - $this->checkAvailability(); |
|
206 | - try { |
|
207 | - return parent::isDeletable($path); |
|
208 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
209 | - $this->setAvailability(false); |
|
210 | - throw $e; |
|
211 | - } |
|
212 | - } |
|
213 | - |
|
214 | - /** {@inheritdoc} */ |
|
215 | - public function isSharable($path) { |
|
216 | - $this->checkAvailability(); |
|
217 | - try { |
|
218 | - return parent::isSharable($path); |
|
219 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
220 | - $this->setAvailability(false); |
|
221 | - throw $e; |
|
222 | - } |
|
223 | - } |
|
224 | - |
|
225 | - /** {@inheritdoc} */ |
|
226 | - public function getPermissions($path) { |
|
227 | - $this->checkAvailability(); |
|
228 | - try { |
|
229 | - return parent::getPermissions($path); |
|
230 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
231 | - $this->setAvailability(false); |
|
232 | - throw $e; |
|
233 | - } |
|
234 | - } |
|
235 | - |
|
236 | - /** {@inheritdoc} */ |
|
237 | - public function file_exists($path) { |
|
238 | - if ($path === '') { |
|
239 | - return true; |
|
240 | - } |
|
241 | - $this->checkAvailability(); |
|
242 | - try { |
|
243 | - return parent::file_exists($path); |
|
244 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
245 | - $this->setAvailability(false); |
|
246 | - throw $e; |
|
247 | - } |
|
248 | - } |
|
249 | - |
|
250 | - /** {@inheritdoc} */ |
|
251 | - public function filemtime($path) { |
|
252 | - $this->checkAvailability(); |
|
253 | - try { |
|
254 | - return parent::filemtime($path); |
|
255 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
256 | - $this->setAvailability(false); |
|
257 | - throw $e; |
|
258 | - } |
|
259 | - } |
|
260 | - |
|
261 | - /** {@inheritdoc} */ |
|
262 | - public function file_get_contents($path) { |
|
263 | - $this->checkAvailability(); |
|
264 | - try { |
|
265 | - return parent::file_get_contents($path); |
|
266 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
267 | - $this->setAvailability(false); |
|
268 | - throw $e; |
|
269 | - } |
|
270 | - } |
|
271 | - |
|
272 | - /** {@inheritdoc} */ |
|
273 | - public function file_put_contents($path, $data) { |
|
274 | - $this->checkAvailability(); |
|
275 | - try { |
|
276 | - return parent::file_put_contents($path, $data); |
|
277 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
278 | - $this->setAvailability(false); |
|
279 | - throw $e; |
|
280 | - } |
|
281 | - } |
|
282 | - |
|
283 | - /** {@inheritdoc} */ |
|
284 | - public function unlink($path) { |
|
285 | - $this->checkAvailability(); |
|
286 | - try { |
|
287 | - return parent::unlink($path); |
|
288 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
289 | - $this->setAvailability(false); |
|
290 | - throw $e; |
|
291 | - } |
|
292 | - } |
|
293 | - |
|
294 | - /** {@inheritdoc} */ |
|
295 | - public function rename($path1, $path2) { |
|
296 | - $this->checkAvailability(); |
|
297 | - try { |
|
298 | - return parent::rename($path1, $path2); |
|
299 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
300 | - $this->setAvailability(false); |
|
301 | - throw $e; |
|
302 | - } |
|
303 | - } |
|
304 | - |
|
305 | - /** {@inheritdoc} */ |
|
306 | - public function copy($path1, $path2) { |
|
307 | - $this->checkAvailability(); |
|
308 | - try { |
|
309 | - return parent::copy($path1, $path2); |
|
310 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
311 | - $this->setAvailability(false); |
|
312 | - throw $e; |
|
313 | - } |
|
314 | - } |
|
315 | - |
|
316 | - /** {@inheritdoc} */ |
|
317 | - public function fopen($path, $mode) { |
|
318 | - $this->checkAvailability(); |
|
319 | - try { |
|
320 | - return parent::fopen($path, $mode); |
|
321 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
322 | - $this->setAvailability(false); |
|
323 | - throw $e; |
|
324 | - } |
|
325 | - } |
|
326 | - |
|
327 | - /** {@inheritdoc} */ |
|
328 | - public function getMimeType($path) { |
|
329 | - $this->checkAvailability(); |
|
330 | - try { |
|
331 | - return parent::getMimeType($path); |
|
332 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
333 | - $this->setAvailability(false); |
|
334 | - throw $e; |
|
335 | - } |
|
336 | - } |
|
337 | - |
|
338 | - /** {@inheritdoc} */ |
|
339 | - public function hash($type, $path, $raw = false) { |
|
340 | - $this->checkAvailability(); |
|
341 | - try { |
|
342 | - return parent::hash($type, $path, $raw); |
|
343 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
344 | - $this->setAvailability(false); |
|
345 | - throw $e; |
|
346 | - } |
|
347 | - } |
|
348 | - |
|
349 | - /** {@inheritdoc} */ |
|
350 | - public function free_space($path) { |
|
351 | - $this->checkAvailability(); |
|
352 | - try { |
|
353 | - return parent::free_space($path); |
|
354 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
355 | - $this->setAvailability(false); |
|
356 | - throw $e; |
|
357 | - } |
|
358 | - } |
|
359 | - |
|
360 | - /** {@inheritdoc} */ |
|
361 | - public function search($query) { |
|
362 | - $this->checkAvailability(); |
|
363 | - try { |
|
364 | - return parent::search($query); |
|
365 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
366 | - $this->setAvailability(false); |
|
367 | - throw $e; |
|
368 | - } |
|
369 | - } |
|
370 | - |
|
371 | - /** {@inheritdoc} */ |
|
372 | - public function touch($path, $mtime = null) { |
|
373 | - $this->checkAvailability(); |
|
374 | - try { |
|
375 | - return parent::touch($path, $mtime); |
|
376 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
377 | - $this->setAvailability(false); |
|
378 | - throw $e; |
|
379 | - } |
|
380 | - } |
|
381 | - |
|
382 | - /** {@inheritdoc} */ |
|
383 | - public function getLocalFile($path) { |
|
384 | - $this->checkAvailability(); |
|
385 | - try { |
|
386 | - return parent::getLocalFile($path); |
|
387 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
388 | - $this->setAvailability(false); |
|
389 | - throw $e; |
|
390 | - } |
|
391 | - } |
|
392 | - |
|
393 | - /** {@inheritdoc} */ |
|
394 | - public function hasUpdated($path, $time) { |
|
395 | - $this->checkAvailability(); |
|
396 | - try { |
|
397 | - return parent::hasUpdated($path, $time); |
|
398 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
399 | - $this->setAvailability(false); |
|
400 | - throw $e; |
|
401 | - } |
|
402 | - } |
|
403 | - |
|
404 | - /** {@inheritdoc} */ |
|
405 | - public function getOwner($path) { |
|
406 | - try { |
|
407 | - return parent::getOwner($path); |
|
408 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
409 | - $this->setAvailability(false); |
|
410 | - throw $e; |
|
411 | - } |
|
412 | - } |
|
413 | - |
|
414 | - /** {@inheritdoc} */ |
|
415 | - public function getETag($path) { |
|
416 | - $this->checkAvailability(); |
|
417 | - try { |
|
418 | - return parent::getETag($path); |
|
419 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
420 | - $this->setAvailability(false); |
|
421 | - throw $e; |
|
422 | - } |
|
423 | - } |
|
424 | - |
|
425 | - /** {@inheritdoc} */ |
|
426 | - public function getDirectDownload($path) { |
|
427 | - $this->checkAvailability(); |
|
428 | - try { |
|
429 | - return parent::getDirectDownload($path); |
|
430 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
431 | - $this->setAvailability(false); |
|
432 | - throw $e; |
|
433 | - } |
|
434 | - } |
|
435 | - |
|
436 | - /** {@inheritdoc} */ |
|
437 | - public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { |
|
438 | - $this->checkAvailability(); |
|
439 | - try { |
|
440 | - return parent::copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); |
|
441 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
442 | - $this->setAvailability(false); |
|
443 | - throw $e; |
|
444 | - } |
|
445 | - } |
|
446 | - |
|
447 | - /** {@inheritdoc} */ |
|
448 | - public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { |
|
449 | - $this->checkAvailability(); |
|
450 | - try { |
|
451 | - return parent::moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); |
|
452 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
453 | - $this->setAvailability(false); |
|
454 | - throw $e; |
|
455 | - } |
|
456 | - } |
|
457 | - |
|
458 | - /** {@inheritdoc} */ |
|
459 | - public function getMetaData($path) { |
|
460 | - $this->checkAvailability(); |
|
461 | - try { |
|
462 | - return parent::getMetaData($path); |
|
463 | - } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
464 | - $this->setAvailability(false); |
|
465 | - throw $e; |
|
466 | - } |
|
467 | - } |
|
33 | + const RECHECK_TTL_SEC = 600; // 10 minutes |
|
34 | + |
|
35 | + public static function shouldRecheck($availability) { |
|
36 | + if (!$availability['available']) { |
|
37 | + // trigger a recheck if TTL reached |
|
38 | + if ((time() - $availability['last_checked']) > self::RECHECK_TTL_SEC) { |
|
39 | + return true; |
|
40 | + } |
|
41 | + } |
|
42 | + return false; |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * Only called if availability === false |
|
47 | + * |
|
48 | + * @return bool |
|
49 | + */ |
|
50 | + private function updateAvailability() { |
|
51 | + // reset availability to false so that multiple requests don't recheck concurrently |
|
52 | + $this->setAvailability(false); |
|
53 | + try { |
|
54 | + $result = $this->test(); |
|
55 | + } catch (\Exception $e) { |
|
56 | + $result = false; |
|
57 | + } |
|
58 | + $this->setAvailability($result); |
|
59 | + return $result; |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * @return bool |
|
64 | + */ |
|
65 | + private function isAvailable() { |
|
66 | + $availability = $this->getAvailability(); |
|
67 | + if (self::shouldRecheck($availability)) { |
|
68 | + return $this->updateAvailability(); |
|
69 | + } |
|
70 | + return $availability['available']; |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * @throws \OCP\Files\StorageNotAvailableException |
|
75 | + */ |
|
76 | + private function checkAvailability() { |
|
77 | + if (!$this->isAvailable()) { |
|
78 | + throw new \OCP\Files\StorageNotAvailableException(); |
|
79 | + } |
|
80 | + } |
|
81 | + |
|
82 | + /** {@inheritdoc} */ |
|
83 | + public function mkdir($path) { |
|
84 | + $this->checkAvailability(); |
|
85 | + try { |
|
86 | + return parent::mkdir($path); |
|
87 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
88 | + $this->setAvailability(false); |
|
89 | + throw $e; |
|
90 | + } |
|
91 | + } |
|
92 | + |
|
93 | + /** {@inheritdoc} */ |
|
94 | + public function rmdir($path) { |
|
95 | + $this->checkAvailability(); |
|
96 | + try { |
|
97 | + return parent::rmdir($path); |
|
98 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
99 | + $this->setAvailability(false); |
|
100 | + throw $e; |
|
101 | + } |
|
102 | + } |
|
103 | + |
|
104 | + /** {@inheritdoc} */ |
|
105 | + public function opendir($path) { |
|
106 | + $this->checkAvailability(); |
|
107 | + try { |
|
108 | + return parent::opendir($path); |
|
109 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
110 | + $this->setAvailability(false); |
|
111 | + throw $e; |
|
112 | + } |
|
113 | + } |
|
114 | + |
|
115 | + /** {@inheritdoc} */ |
|
116 | + public function is_dir($path) { |
|
117 | + $this->checkAvailability(); |
|
118 | + try { |
|
119 | + return parent::is_dir($path); |
|
120 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
121 | + $this->setAvailability(false); |
|
122 | + throw $e; |
|
123 | + } |
|
124 | + } |
|
125 | + |
|
126 | + /** {@inheritdoc} */ |
|
127 | + public function is_file($path) { |
|
128 | + $this->checkAvailability(); |
|
129 | + try { |
|
130 | + return parent::is_file($path); |
|
131 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
132 | + $this->setAvailability(false); |
|
133 | + throw $e; |
|
134 | + } |
|
135 | + } |
|
136 | + |
|
137 | + /** {@inheritdoc} */ |
|
138 | + public function stat($path) { |
|
139 | + $this->checkAvailability(); |
|
140 | + try { |
|
141 | + return parent::stat($path); |
|
142 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
143 | + $this->setAvailability(false); |
|
144 | + throw $e; |
|
145 | + } |
|
146 | + } |
|
147 | + |
|
148 | + /** {@inheritdoc} */ |
|
149 | + public function filetype($path) { |
|
150 | + $this->checkAvailability(); |
|
151 | + try { |
|
152 | + return parent::filetype($path); |
|
153 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
154 | + $this->setAvailability(false); |
|
155 | + throw $e; |
|
156 | + } |
|
157 | + } |
|
158 | + |
|
159 | + /** {@inheritdoc} */ |
|
160 | + public function filesize($path) { |
|
161 | + $this->checkAvailability(); |
|
162 | + try { |
|
163 | + return parent::filesize($path); |
|
164 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
165 | + $this->setAvailability(false); |
|
166 | + throw $e; |
|
167 | + } |
|
168 | + } |
|
169 | + |
|
170 | + /** {@inheritdoc} */ |
|
171 | + public function isCreatable($path) { |
|
172 | + $this->checkAvailability(); |
|
173 | + try { |
|
174 | + return parent::isCreatable($path); |
|
175 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
176 | + $this->setAvailability(false); |
|
177 | + throw $e; |
|
178 | + } |
|
179 | + } |
|
180 | + |
|
181 | + /** {@inheritdoc} */ |
|
182 | + public function isReadable($path) { |
|
183 | + $this->checkAvailability(); |
|
184 | + try { |
|
185 | + return parent::isReadable($path); |
|
186 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
187 | + $this->setAvailability(false); |
|
188 | + throw $e; |
|
189 | + } |
|
190 | + } |
|
191 | + |
|
192 | + /** {@inheritdoc} */ |
|
193 | + public function isUpdatable($path) { |
|
194 | + $this->checkAvailability(); |
|
195 | + try { |
|
196 | + return parent::isUpdatable($path); |
|
197 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
198 | + $this->setAvailability(false); |
|
199 | + throw $e; |
|
200 | + } |
|
201 | + } |
|
202 | + |
|
203 | + /** {@inheritdoc} */ |
|
204 | + public function isDeletable($path) { |
|
205 | + $this->checkAvailability(); |
|
206 | + try { |
|
207 | + return parent::isDeletable($path); |
|
208 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
209 | + $this->setAvailability(false); |
|
210 | + throw $e; |
|
211 | + } |
|
212 | + } |
|
213 | + |
|
214 | + /** {@inheritdoc} */ |
|
215 | + public function isSharable($path) { |
|
216 | + $this->checkAvailability(); |
|
217 | + try { |
|
218 | + return parent::isSharable($path); |
|
219 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
220 | + $this->setAvailability(false); |
|
221 | + throw $e; |
|
222 | + } |
|
223 | + } |
|
224 | + |
|
225 | + /** {@inheritdoc} */ |
|
226 | + public function getPermissions($path) { |
|
227 | + $this->checkAvailability(); |
|
228 | + try { |
|
229 | + return parent::getPermissions($path); |
|
230 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
231 | + $this->setAvailability(false); |
|
232 | + throw $e; |
|
233 | + } |
|
234 | + } |
|
235 | + |
|
236 | + /** {@inheritdoc} */ |
|
237 | + public function file_exists($path) { |
|
238 | + if ($path === '') { |
|
239 | + return true; |
|
240 | + } |
|
241 | + $this->checkAvailability(); |
|
242 | + try { |
|
243 | + return parent::file_exists($path); |
|
244 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
245 | + $this->setAvailability(false); |
|
246 | + throw $e; |
|
247 | + } |
|
248 | + } |
|
249 | + |
|
250 | + /** {@inheritdoc} */ |
|
251 | + public function filemtime($path) { |
|
252 | + $this->checkAvailability(); |
|
253 | + try { |
|
254 | + return parent::filemtime($path); |
|
255 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
256 | + $this->setAvailability(false); |
|
257 | + throw $e; |
|
258 | + } |
|
259 | + } |
|
260 | + |
|
261 | + /** {@inheritdoc} */ |
|
262 | + public function file_get_contents($path) { |
|
263 | + $this->checkAvailability(); |
|
264 | + try { |
|
265 | + return parent::file_get_contents($path); |
|
266 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
267 | + $this->setAvailability(false); |
|
268 | + throw $e; |
|
269 | + } |
|
270 | + } |
|
271 | + |
|
272 | + /** {@inheritdoc} */ |
|
273 | + public function file_put_contents($path, $data) { |
|
274 | + $this->checkAvailability(); |
|
275 | + try { |
|
276 | + return parent::file_put_contents($path, $data); |
|
277 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
278 | + $this->setAvailability(false); |
|
279 | + throw $e; |
|
280 | + } |
|
281 | + } |
|
282 | + |
|
283 | + /** {@inheritdoc} */ |
|
284 | + public function unlink($path) { |
|
285 | + $this->checkAvailability(); |
|
286 | + try { |
|
287 | + return parent::unlink($path); |
|
288 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
289 | + $this->setAvailability(false); |
|
290 | + throw $e; |
|
291 | + } |
|
292 | + } |
|
293 | + |
|
294 | + /** {@inheritdoc} */ |
|
295 | + public function rename($path1, $path2) { |
|
296 | + $this->checkAvailability(); |
|
297 | + try { |
|
298 | + return parent::rename($path1, $path2); |
|
299 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
300 | + $this->setAvailability(false); |
|
301 | + throw $e; |
|
302 | + } |
|
303 | + } |
|
304 | + |
|
305 | + /** {@inheritdoc} */ |
|
306 | + public function copy($path1, $path2) { |
|
307 | + $this->checkAvailability(); |
|
308 | + try { |
|
309 | + return parent::copy($path1, $path2); |
|
310 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
311 | + $this->setAvailability(false); |
|
312 | + throw $e; |
|
313 | + } |
|
314 | + } |
|
315 | + |
|
316 | + /** {@inheritdoc} */ |
|
317 | + public function fopen($path, $mode) { |
|
318 | + $this->checkAvailability(); |
|
319 | + try { |
|
320 | + return parent::fopen($path, $mode); |
|
321 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
322 | + $this->setAvailability(false); |
|
323 | + throw $e; |
|
324 | + } |
|
325 | + } |
|
326 | + |
|
327 | + /** {@inheritdoc} */ |
|
328 | + public function getMimeType($path) { |
|
329 | + $this->checkAvailability(); |
|
330 | + try { |
|
331 | + return parent::getMimeType($path); |
|
332 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
333 | + $this->setAvailability(false); |
|
334 | + throw $e; |
|
335 | + } |
|
336 | + } |
|
337 | + |
|
338 | + /** {@inheritdoc} */ |
|
339 | + public function hash($type, $path, $raw = false) { |
|
340 | + $this->checkAvailability(); |
|
341 | + try { |
|
342 | + return parent::hash($type, $path, $raw); |
|
343 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
344 | + $this->setAvailability(false); |
|
345 | + throw $e; |
|
346 | + } |
|
347 | + } |
|
348 | + |
|
349 | + /** {@inheritdoc} */ |
|
350 | + public function free_space($path) { |
|
351 | + $this->checkAvailability(); |
|
352 | + try { |
|
353 | + return parent::free_space($path); |
|
354 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
355 | + $this->setAvailability(false); |
|
356 | + throw $e; |
|
357 | + } |
|
358 | + } |
|
359 | + |
|
360 | + /** {@inheritdoc} */ |
|
361 | + public function search($query) { |
|
362 | + $this->checkAvailability(); |
|
363 | + try { |
|
364 | + return parent::search($query); |
|
365 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
366 | + $this->setAvailability(false); |
|
367 | + throw $e; |
|
368 | + } |
|
369 | + } |
|
370 | + |
|
371 | + /** {@inheritdoc} */ |
|
372 | + public function touch($path, $mtime = null) { |
|
373 | + $this->checkAvailability(); |
|
374 | + try { |
|
375 | + return parent::touch($path, $mtime); |
|
376 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
377 | + $this->setAvailability(false); |
|
378 | + throw $e; |
|
379 | + } |
|
380 | + } |
|
381 | + |
|
382 | + /** {@inheritdoc} */ |
|
383 | + public function getLocalFile($path) { |
|
384 | + $this->checkAvailability(); |
|
385 | + try { |
|
386 | + return parent::getLocalFile($path); |
|
387 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
388 | + $this->setAvailability(false); |
|
389 | + throw $e; |
|
390 | + } |
|
391 | + } |
|
392 | + |
|
393 | + /** {@inheritdoc} */ |
|
394 | + public function hasUpdated($path, $time) { |
|
395 | + $this->checkAvailability(); |
|
396 | + try { |
|
397 | + return parent::hasUpdated($path, $time); |
|
398 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
399 | + $this->setAvailability(false); |
|
400 | + throw $e; |
|
401 | + } |
|
402 | + } |
|
403 | + |
|
404 | + /** {@inheritdoc} */ |
|
405 | + public function getOwner($path) { |
|
406 | + try { |
|
407 | + return parent::getOwner($path); |
|
408 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
409 | + $this->setAvailability(false); |
|
410 | + throw $e; |
|
411 | + } |
|
412 | + } |
|
413 | + |
|
414 | + /** {@inheritdoc} */ |
|
415 | + public function getETag($path) { |
|
416 | + $this->checkAvailability(); |
|
417 | + try { |
|
418 | + return parent::getETag($path); |
|
419 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
420 | + $this->setAvailability(false); |
|
421 | + throw $e; |
|
422 | + } |
|
423 | + } |
|
424 | + |
|
425 | + /** {@inheritdoc} */ |
|
426 | + public function getDirectDownload($path) { |
|
427 | + $this->checkAvailability(); |
|
428 | + try { |
|
429 | + return parent::getDirectDownload($path); |
|
430 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
431 | + $this->setAvailability(false); |
|
432 | + throw $e; |
|
433 | + } |
|
434 | + } |
|
435 | + |
|
436 | + /** {@inheritdoc} */ |
|
437 | + public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { |
|
438 | + $this->checkAvailability(); |
|
439 | + try { |
|
440 | + return parent::copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); |
|
441 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
442 | + $this->setAvailability(false); |
|
443 | + throw $e; |
|
444 | + } |
|
445 | + } |
|
446 | + |
|
447 | + /** {@inheritdoc} */ |
|
448 | + public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { |
|
449 | + $this->checkAvailability(); |
|
450 | + try { |
|
451 | + return parent::moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); |
|
452 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
453 | + $this->setAvailability(false); |
|
454 | + throw $e; |
|
455 | + } |
|
456 | + } |
|
457 | + |
|
458 | + /** {@inheritdoc} */ |
|
459 | + public function getMetaData($path) { |
|
460 | + $this->checkAvailability(); |
|
461 | + try { |
|
462 | + return parent::getMetaData($path); |
|
463 | + } catch (\OCP\Files\StorageNotAvailableException $e) { |
|
464 | + $this->setAvailability(false); |
|
465 | + throw $e; |
|
466 | + } |
|
467 | + } |
|
468 | 468 | } |
@@ -30,114 +30,114 @@ |
||
30 | 30 | * @since 8.0.0 |
31 | 31 | */ |
32 | 32 | interface IDateTimeFormatter { |
33 | - /** |
|
34 | - * Formats the date of the given timestamp |
|
35 | - * |
|
36 | - * @param int|\DateTime $timestamp |
|
37 | - * @param string $format Either 'full', 'long', 'medium' or 'short' |
|
38 | - * full: e.g. 'EEEE, MMMM d, y' => 'Wednesday, August 20, 2014' |
|
39 | - * long: e.g. 'MMMM d, y' => 'August 20, 2014' |
|
40 | - * medium: e.g. 'MMM d, y' => 'Aug 20, 2014' |
|
41 | - * short: e.g. 'M/d/yy' => '8/20/14' |
|
42 | - * The exact format is dependent on the language |
|
43 | - * @param \DateTimeZone|null $timeZone The timezone to use |
|
44 | - * @param \OCP\IL10N|null $l The locale to use |
|
45 | - * @return string Formatted date string |
|
46 | - * @since 8.0.0 |
|
47 | - */ |
|
48 | - public function formatDate($timestamp, $format = 'long', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null); |
|
33 | + /** |
|
34 | + * Formats the date of the given timestamp |
|
35 | + * |
|
36 | + * @param int|\DateTime $timestamp |
|
37 | + * @param string $format Either 'full', 'long', 'medium' or 'short' |
|
38 | + * full: e.g. 'EEEE, MMMM d, y' => 'Wednesday, August 20, 2014' |
|
39 | + * long: e.g. 'MMMM d, y' => 'August 20, 2014' |
|
40 | + * medium: e.g. 'MMM d, y' => 'Aug 20, 2014' |
|
41 | + * short: e.g. 'M/d/yy' => '8/20/14' |
|
42 | + * The exact format is dependent on the language |
|
43 | + * @param \DateTimeZone|null $timeZone The timezone to use |
|
44 | + * @param \OCP\IL10N|null $l The locale to use |
|
45 | + * @return string Formatted date string |
|
46 | + * @since 8.0.0 |
|
47 | + */ |
|
48 | + public function formatDate($timestamp, $format = 'long', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null); |
|
49 | 49 | |
50 | - /** |
|
51 | - * Formats the date of the given timestamp |
|
52 | - * |
|
53 | - * @param int|\DateTime $timestamp |
|
54 | - * @param string $format Either 'full', 'long', 'medium' or 'short' |
|
55 | - * full: e.g. 'EEEE, MMMM d, y' => 'Wednesday, August 20, 2014' |
|
56 | - * long: e.g. 'MMMM d, y' => 'August 20, 2014' |
|
57 | - * medium: e.g. 'MMM d, y' => 'Aug 20, 2014' |
|
58 | - * short: e.g. 'M/d/yy' => '8/20/14' |
|
59 | - * The exact format is dependent on the language |
|
60 | - * Uses 'Today', 'Yesterday' and 'Tomorrow' when applicable |
|
61 | - * @param \DateTimeZone|null $timeZone The timezone to use |
|
62 | - * @param \OCP\IL10N|null $l The locale to use |
|
63 | - * @return string Formatted relative date string |
|
64 | - * @since 8.0.0 |
|
65 | - */ |
|
66 | - public function formatDateRelativeDay($timestamp, $format = 'long', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null); |
|
50 | + /** |
|
51 | + * Formats the date of the given timestamp |
|
52 | + * |
|
53 | + * @param int|\DateTime $timestamp |
|
54 | + * @param string $format Either 'full', 'long', 'medium' or 'short' |
|
55 | + * full: e.g. 'EEEE, MMMM d, y' => 'Wednesday, August 20, 2014' |
|
56 | + * long: e.g. 'MMMM d, y' => 'August 20, 2014' |
|
57 | + * medium: e.g. 'MMM d, y' => 'Aug 20, 2014' |
|
58 | + * short: e.g. 'M/d/yy' => '8/20/14' |
|
59 | + * The exact format is dependent on the language |
|
60 | + * Uses 'Today', 'Yesterday' and 'Tomorrow' when applicable |
|
61 | + * @param \DateTimeZone|null $timeZone The timezone to use |
|
62 | + * @param \OCP\IL10N|null $l The locale to use |
|
63 | + * @return string Formatted relative date string |
|
64 | + * @since 8.0.0 |
|
65 | + */ |
|
66 | + public function formatDateRelativeDay($timestamp, $format = 'long', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null); |
|
67 | 67 | |
68 | - /** |
|
69 | - * Gives the relative date of the timestamp |
|
70 | - * Only works for past dates |
|
71 | - * |
|
72 | - * @param int|\DateTime $timestamp |
|
73 | - * @param int|\DateTime|null $baseTimestamp Timestamp to compare $timestamp against, defaults to current time |
|
74 | - * @param \OCP\IL10N|null $l The locale to use |
|
75 | - * @return string Dates returned are: |
|
76 | - * < 1 month => Today, Yesterday, n days ago |
|
77 | - * < 13 month => last month, n months ago |
|
78 | - * >= 13 month => last year, n years ago |
|
79 | - * @since 8.0.0 |
|
80 | - */ |
|
81 | - public function formatDateSpan($timestamp, $baseTimestamp = null, \OCP\IL10N $l = null); |
|
68 | + /** |
|
69 | + * Gives the relative date of the timestamp |
|
70 | + * Only works for past dates |
|
71 | + * |
|
72 | + * @param int|\DateTime $timestamp |
|
73 | + * @param int|\DateTime|null $baseTimestamp Timestamp to compare $timestamp against, defaults to current time |
|
74 | + * @param \OCP\IL10N|null $l The locale to use |
|
75 | + * @return string Dates returned are: |
|
76 | + * < 1 month => Today, Yesterday, n days ago |
|
77 | + * < 13 month => last month, n months ago |
|
78 | + * >= 13 month => last year, n years ago |
|
79 | + * @since 8.0.0 |
|
80 | + */ |
|
81 | + public function formatDateSpan($timestamp, $baseTimestamp = null, \OCP\IL10N $l = null); |
|
82 | 82 | |
83 | - /** |
|
84 | - * Formats the time of the given timestamp |
|
85 | - * |
|
86 | - * @param int|\DateTime $timestamp |
|
87 | - * @param string $format Either 'full', 'long', 'medium' or 'short' |
|
88 | - * full: e.g. 'h:mm:ss a zzzz' => '11:42:13 AM GMT+0:00' |
|
89 | - * long: e.g. 'h:mm:ss a z' => '11:42:13 AM GMT' |
|
90 | - * medium: e.g. 'h:mm:ss a' => '11:42:13 AM' |
|
91 | - * short: e.g. 'h:mm a' => '11:42 AM' |
|
92 | - * The exact format is dependent on the language |
|
93 | - * @param \DateTimeZone|null $timeZone The timezone to use |
|
94 | - * @param \OCP\IL10N|null $l The locale to use |
|
95 | - * @return string Formatted time string |
|
96 | - * @since 8.0.0 |
|
97 | - */ |
|
98 | - public function formatTime($timestamp, $format = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null); |
|
83 | + /** |
|
84 | + * Formats the time of the given timestamp |
|
85 | + * |
|
86 | + * @param int|\DateTime $timestamp |
|
87 | + * @param string $format Either 'full', 'long', 'medium' or 'short' |
|
88 | + * full: e.g. 'h:mm:ss a zzzz' => '11:42:13 AM GMT+0:00' |
|
89 | + * long: e.g. 'h:mm:ss a z' => '11:42:13 AM GMT' |
|
90 | + * medium: e.g. 'h:mm:ss a' => '11:42:13 AM' |
|
91 | + * short: e.g. 'h:mm a' => '11:42 AM' |
|
92 | + * The exact format is dependent on the language |
|
93 | + * @param \DateTimeZone|null $timeZone The timezone to use |
|
94 | + * @param \OCP\IL10N|null $l The locale to use |
|
95 | + * @return string Formatted time string |
|
96 | + * @since 8.0.0 |
|
97 | + */ |
|
98 | + public function formatTime($timestamp, $format = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null); |
|
99 | 99 | |
100 | - /** |
|
101 | - * Gives the relative past time of the timestamp |
|
102 | - * |
|
103 | - * @param int|\DateTime $timestamp |
|
104 | - * @param int|\DateTime|null $baseTimestamp Timestamp to compare $timestamp against, defaults to current time |
|
105 | - * @param \OCP\IL10N|null $l The locale to use |
|
106 | - * @return string Dates returned are: |
|
107 | - * < 60 sec => seconds ago |
|
108 | - * < 1 hour => n minutes ago |
|
109 | - * < 1 day => n hours ago |
|
110 | - * < 1 month => Yesterday, n days ago |
|
111 | - * < 13 month => last month, n months ago |
|
112 | - * >= 13 month => last year, n years ago |
|
113 | - * @since 8.0.0 |
|
114 | - */ |
|
115 | - public function formatTimeSpan($timestamp, $baseTimestamp = null, \OCP\IL10N $l = null); |
|
100 | + /** |
|
101 | + * Gives the relative past time of the timestamp |
|
102 | + * |
|
103 | + * @param int|\DateTime $timestamp |
|
104 | + * @param int|\DateTime|null $baseTimestamp Timestamp to compare $timestamp against, defaults to current time |
|
105 | + * @param \OCP\IL10N|null $l The locale to use |
|
106 | + * @return string Dates returned are: |
|
107 | + * < 60 sec => seconds ago |
|
108 | + * < 1 hour => n minutes ago |
|
109 | + * < 1 day => n hours ago |
|
110 | + * < 1 month => Yesterday, n days ago |
|
111 | + * < 13 month => last month, n months ago |
|
112 | + * >= 13 month => last year, n years ago |
|
113 | + * @since 8.0.0 |
|
114 | + */ |
|
115 | + public function formatTimeSpan($timestamp, $baseTimestamp = null, \OCP\IL10N $l = null); |
|
116 | 116 | |
117 | - /** |
|
118 | - * Formats the date and time of the given timestamp |
|
119 | - * |
|
120 | - * @param int|\DateTime $timestamp |
|
121 | - * @param string $formatDate See formatDate() for description |
|
122 | - * @param string $formatTime See formatTime() for description |
|
123 | - * @param \DateTimeZone|null $timeZone The timezone to use |
|
124 | - * @param \OCP\IL10N|null $l The locale to use |
|
125 | - * @return string Formatted date and time string |
|
126 | - * @since 8.0.0 |
|
127 | - */ |
|
128 | - public function formatDateTime($timestamp, $formatDate = 'long', $formatTime = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null); |
|
117 | + /** |
|
118 | + * Formats the date and time of the given timestamp |
|
119 | + * |
|
120 | + * @param int|\DateTime $timestamp |
|
121 | + * @param string $formatDate See formatDate() for description |
|
122 | + * @param string $formatTime See formatTime() for description |
|
123 | + * @param \DateTimeZone|null $timeZone The timezone to use |
|
124 | + * @param \OCP\IL10N|null $l The locale to use |
|
125 | + * @return string Formatted date and time string |
|
126 | + * @since 8.0.0 |
|
127 | + */ |
|
128 | + public function formatDateTime($timestamp, $formatDate = 'long', $formatTime = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null); |
|
129 | 129 | |
130 | - /** |
|
131 | - * Formats the date and time of the given timestamp |
|
132 | - * |
|
133 | - * @param int|\DateTime $timestamp |
|
134 | - * @param string $formatDate See formatDate() for description |
|
135 | - * Uses 'Today', 'Yesterday' and 'Tomorrow' when applicable |
|
136 | - * @param string $formatTime See formatTime() for description |
|
137 | - * @param \DateTimeZone|null $timeZone The timezone to use |
|
138 | - * @param \OCP\IL10N|null $l The locale to use |
|
139 | - * @return string Formatted relative date and time string |
|
140 | - * @since 8.0.0 |
|
141 | - */ |
|
142 | - public function formatDateTimeRelativeDay($timestamp, $formatDate = 'long', $formatTime = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null); |
|
130 | + /** |
|
131 | + * Formats the date and time of the given timestamp |
|
132 | + * |
|
133 | + * @param int|\DateTime $timestamp |
|
134 | + * @param string $formatDate See formatDate() for description |
|
135 | + * Uses 'Today', 'Yesterday' and 'Tomorrow' when applicable |
|
136 | + * @param string $formatTime See formatTime() for description |
|
137 | + * @param \DateTimeZone|null $timeZone The timezone to use |
|
138 | + * @param \OCP\IL10N|null $l The locale to use |
|
139 | + * @return string Formatted relative date and time string |
|
140 | + * @since 8.0.0 |
|
141 | + */ |
|
142 | + public function formatDateTimeRelativeDay($timestamp, $formatDate = 'long', $formatTime = 'medium', \DateTimeZone $timeZone = null, \OCP\IL10N $l = null); |
|
143 | 143 | } |
@@ -30,39 +30,39 @@ |
||
30 | 30 | */ |
31 | 31 | abstract class PagedProvider extends Provider { |
32 | 32 | |
33 | - /** |
|
34 | - * show all results |
|
35 | - * @since 8.0.0 |
|
36 | - */ |
|
37 | - const SIZE_ALL = 0; |
|
33 | + /** |
|
34 | + * show all results |
|
35 | + * @since 8.0.0 |
|
36 | + */ |
|
37 | + const SIZE_ALL = 0; |
|
38 | 38 | |
39 | - /** |
|
40 | - * Constructor |
|
41 | - * @param array $options |
|
42 | - * @since 8.0.0 |
|
43 | - */ |
|
44 | - public function __construct($options) { |
|
45 | - parent::__construct($options); |
|
46 | - } |
|
39 | + /** |
|
40 | + * Constructor |
|
41 | + * @param array $options |
|
42 | + * @since 8.0.0 |
|
43 | + */ |
|
44 | + public function __construct($options) { |
|
45 | + parent::__construct($options); |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Search for $query |
|
50 | - * @param string $query |
|
51 | - * @return array An array of OCP\Search\Result's |
|
52 | - * @since 8.0.0 |
|
53 | - */ |
|
54 | - public function search($query) { |
|
55 | - // old apps might assume they get all results, so we use SIZE_ALL |
|
56 | - return $this->searchPaged($query, 1, self::SIZE_ALL); |
|
57 | - } |
|
48 | + /** |
|
49 | + * Search for $query |
|
50 | + * @param string $query |
|
51 | + * @return array An array of OCP\Search\Result's |
|
52 | + * @since 8.0.0 |
|
53 | + */ |
|
54 | + public function search($query) { |
|
55 | + // old apps might assume they get all results, so we use SIZE_ALL |
|
56 | + return $this->searchPaged($query, 1, self::SIZE_ALL); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Search for $query |
|
61 | - * @param string $query |
|
62 | - * @param int $page pages start at page 1 |
|
63 | - * @param int $size 0 = SIZE_ALL |
|
64 | - * @return array An array of OCP\Search\Result's |
|
65 | - * @since 8.0.0 |
|
66 | - */ |
|
67 | - abstract public function searchPaged($query, $page, $size); |
|
59 | + /** |
|
60 | + * Search for $query |
|
61 | + * @param string $query |
|
62 | + * @param int $page pages start at page 1 |
|
63 | + * @param int $size 0 = SIZE_ALL |
|
64 | + * @return array An array of OCP\Search\Result's |
|
65 | + * @since 8.0.0 |
|
66 | + */ |
|
67 | + abstract public function searchPaged($query, $page, $size); |
|
68 | 68 | } |
@@ -31,18 +31,18 @@ |
||
31 | 31 | */ |
32 | 32 | class GenericShareException extends HintException { |
33 | 33 | |
34 | - /** |
|
35 | - * @param string $message |
|
36 | - * @param string $hint |
|
37 | - * @param int $code |
|
38 | - * @param \Exception|null $previous |
|
39 | - * @since 9.0.0 |
|
40 | - */ |
|
41 | - public function __construct($message = '', $hint = '', $code = 0, \Exception $previous = null) { |
|
42 | - if (empty($message)) { |
|
43 | - $message = 'There was an error retrieving the share. Maybe the link is wrong, it was unshared, or it was deleted.'; |
|
44 | - } |
|
45 | - parent::__construct($message, $hint, $code, $previous); |
|
46 | - } |
|
34 | + /** |
|
35 | + * @param string $message |
|
36 | + * @param string $hint |
|
37 | + * @param int $code |
|
38 | + * @param \Exception|null $previous |
|
39 | + * @since 9.0.0 |
|
40 | + */ |
|
41 | + public function __construct($message = '', $hint = '', $code = 0, \Exception $previous = null) { |
|
42 | + if (empty($message)) { |
|
43 | + $message = 'There was an error retrieving the share. Maybe the link is wrong, it was unshared, or it was deleted.'; |
|
44 | + } |
|
45 | + parent::__construct($message, $hint, $code, $previous); |
|
46 | + } |
|
47 | 47 | |
48 | 48 | } |
@@ -32,56 +32,56 @@ |
||
32 | 32 | * @since 7.0.0 |
33 | 33 | */ |
34 | 34 | interface IJob { |
35 | - /** |
|
36 | - * Run the background job with the registered argument |
|
37 | - * |
|
38 | - * @param \OCP\BackgroundJob\IJobList $jobList The job list that manages the state of this job |
|
39 | - * @param ILogger|null $logger |
|
40 | - * @since 7.0.0 |
|
41 | - */ |
|
42 | - public function execute($jobList, ILogger $logger = null); |
|
35 | + /** |
|
36 | + * Run the background job with the registered argument |
|
37 | + * |
|
38 | + * @param \OCP\BackgroundJob\IJobList $jobList The job list that manages the state of this job |
|
39 | + * @param ILogger|null $logger |
|
40 | + * @since 7.0.0 |
|
41 | + */ |
|
42 | + public function execute($jobList, ILogger $logger = null); |
|
43 | 43 | |
44 | - /** |
|
45 | - * @param int $id |
|
46 | - * @since 7.0.0 |
|
47 | - */ |
|
48 | - public function setId($id); |
|
44 | + /** |
|
45 | + * @param int $id |
|
46 | + * @since 7.0.0 |
|
47 | + */ |
|
48 | + public function setId($id); |
|
49 | 49 | |
50 | - /** |
|
51 | - * @param int $lastRun |
|
52 | - * @since 7.0.0 |
|
53 | - */ |
|
54 | - public function setLastRun($lastRun); |
|
50 | + /** |
|
51 | + * @param int $lastRun |
|
52 | + * @since 7.0.0 |
|
53 | + */ |
|
54 | + public function setLastRun($lastRun); |
|
55 | 55 | |
56 | - /** |
|
57 | - * @param mixed $argument |
|
58 | - * @since 7.0.0 |
|
59 | - */ |
|
60 | - public function setArgument($argument); |
|
56 | + /** |
|
57 | + * @param mixed $argument |
|
58 | + * @since 7.0.0 |
|
59 | + */ |
|
60 | + public function setArgument($argument); |
|
61 | 61 | |
62 | - /** |
|
63 | - * Get the id of the background job |
|
64 | - * This id is determined by the job list when a job is added to the list |
|
65 | - * |
|
66 | - * @return int |
|
67 | - * @since 7.0.0 |
|
68 | - */ |
|
69 | - public function getId(); |
|
62 | + /** |
|
63 | + * Get the id of the background job |
|
64 | + * This id is determined by the job list when a job is added to the list |
|
65 | + * |
|
66 | + * @return int |
|
67 | + * @since 7.0.0 |
|
68 | + */ |
|
69 | + public function getId(); |
|
70 | 70 | |
71 | - /** |
|
72 | - * Get the last time this job was run as unix timestamp |
|
73 | - * |
|
74 | - * @return int |
|
75 | - * @since 7.0.0 |
|
76 | - */ |
|
77 | - public function getLastRun(); |
|
71 | + /** |
|
72 | + * Get the last time this job was run as unix timestamp |
|
73 | + * |
|
74 | + * @return int |
|
75 | + * @since 7.0.0 |
|
76 | + */ |
|
77 | + public function getLastRun(); |
|
78 | 78 | |
79 | - /** |
|
80 | - * Get the argument associated with the background job |
|
81 | - * This is the argument that will be passed to the background job |
|
82 | - * |
|
83 | - * @return mixed |
|
84 | - * @since 7.0.0 |
|
85 | - */ |
|
86 | - public function getArgument(); |
|
79 | + /** |
|
80 | + * Get the argument associated with the background job |
|
81 | + * This is the argument that will be passed to the background job |
|
82 | + * |
|
83 | + * @return mixed |
|
84 | + * @since 7.0.0 |
|
85 | + */ |
|
86 | + public function getArgument(); |
|
87 | 87 | } |
@@ -35,18 +35,18 @@ |
||
35 | 35 | */ |
36 | 36 | class GenericEncryptionException extends HintException { |
37 | 37 | |
38 | - /** |
|
39 | - * @param string $message |
|
40 | - * @param string $hint |
|
41 | - * @param int $code |
|
42 | - * @param \Exception|null $previous |
|
43 | - * @since 8.1.0 |
|
44 | - */ |
|
45 | - public function __construct($message = '', $hint = '', $code = 0, \Exception $previous = null) { |
|
46 | - if (empty($message)) { |
|
47 | - $message = 'Unspecified encryption exception'; |
|
48 | - } |
|
49 | - parent::__construct($message, $hint, $code, $previous); |
|
50 | - } |
|
38 | + /** |
|
39 | + * @param string $message |
|
40 | + * @param string $hint |
|
41 | + * @param int $code |
|
42 | + * @param \Exception|null $previous |
|
43 | + * @since 8.1.0 |
|
44 | + */ |
|
45 | + public function __construct($message = '', $hint = '', $code = 0, \Exception $previous = null) { |
|
46 | + if (empty($message)) { |
|
47 | + $message = 'Unspecified encryption exception'; |
|
48 | + } |
|
49 | + parent::__construct($message, $hint, $code, $previous); |
|
50 | + } |
|
51 | 51 | |
52 | 52 | } |
@@ -33,43 +33,43 @@ |
||
33 | 33 | * @since 8.0.0 |
34 | 34 | */ |
35 | 35 | interface IQueryLogger extends SQLLogger { |
36 | - /** |
|
37 | - * Mark the start of a query providing query SQL statement, its parameters and types. |
|
38 | - * This method should be called as close to the DB as possible and after |
|
39 | - * query is finished finalized with stopQuery() method. |
|
40 | - * |
|
41 | - * @param string $sql |
|
42 | - * @param array|null $params |
|
43 | - * @param array|null $types |
|
44 | - * @since 8.0.0 |
|
45 | - */ |
|
46 | - public function startQuery($sql, array $params = null, array $types = null); |
|
36 | + /** |
|
37 | + * Mark the start of a query providing query SQL statement, its parameters and types. |
|
38 | + * This method should be called as close to the DB as possible and after |
|
39 | + * query is finished finalized with stopQuery() method. |
|
40 | + * |
|
41 | + * @param string $sql |
|
42 | + * @param array|null $params |
|
43 | + * @param array|null $types |
|
44 | + * @since 8.0.0 |
|
45 | + */ |
|
46 | + public function startQuery($sql, array $params = null, array $types = null); |
|
47 | 47 | |
48 | - /** |
|
49 | - * Mark the end of the current active query. Ending query should store \OCP\Diagnostics\IQuery to |
|
50 | - * be returned with getQueries() method. |
|
51 | - * |
|
52 | - * @return mixed |
|
53 | - * @since 8.0.0 |
|
54 | - */ |
|
55 | - public function stopQuery(); |
|
48 | + /** |
|
49 | + * Mark the end of the current active query. Ending query should store \OCP\Diagnostics\IQuery to |
|
50 | + * be returned with getQueries() method. |
|
51 | + * |
|
52 | + * @return mixed |
|
53 | + * @since 8.0.0 |
|
54 | + */ |
|
55 | + public function stopQuery(); |
|
56 | 56 | |
57 | - /** |
|
58 | - * This method should return all \OCP\Diagnostics\IQuery objects stored using |
|
59 | - * startQuery()/stopQuery() methods. |
|
60 | - * |
|
61 | - * @return \OCP\Diagnostics\IQuery[] |
|
62 | - * @since 8.0.0 |
|
63 | - */ |
|
64 | - public function getQueries(); |
|
57 | + /** |
|
58 | + * This method should return all \OCP\Diagnostics\IQuery objects stored using |
|
59 | + * startQuery()/stopQuery() methods. |
|
60 | + * |
|
61 | + * @return \OCP\Diagnostics\IQuery[] |
|
62 | + * @since 8.0.0 |
|
63 | + */ |
|
64 | + public function getQueries(); |
|
65 | 65 | |
66 | - /** |
|
67 | - * Activate the module for the duration of the request. Deactivated module |
|
68 | - * does not create and store \OCP\Diagnostics\IQuery objects. |
|
69 | - * Only activated module should create and store objects to be |
|
70 | - * returned with getQueries() call. |
|
71 | - * |
|
72 | - * @since 12.0.0 |
|
73 | - */ |
|
74 | - public function activate(); |
|
66 | + /** |
|
67 | + * Activate the module for the duration of the request. Deactivated module |
|
68 | + * does not create and store \OCP\Diagnostics\IQuery objects. |
|
69 | + * Only activated module should create and store objects to be |
|
70 | + * returned with getQueries() call. |
|
71 | + * |
|
72 | + * @since 12.0.0 |
|
73 | + */ |
|
74 | + public function activate(); |
|
75 | 75 | } |
@@ -47,417 +47,417 @@ |
||
47 | 47 | * @deprecated 9.0.0 use \OCP\Files\Storage\IStorage instead |
48 | 48 | */ |
49 | 49 | interface Storage extends IStorage { |
50 | - /** |
|
51 | - * $parameters is a free form array with the configuration options needed to construct the storage |
|
52 | - * |
|
53 | - * @param array $parameters |
|
54 | - * @since 6.0.0 |
|
55 | - */ |
|
56 | - public function __construct($parameters); |
|
57 | - |
|
58 | - /** |
|
59 | - * Get the identifier for the storage, |
|
60 | - * the returned id should be the same for every storage object that is created with the same parameters |
|
61 | - * and two storage objects with the same id should refer to two storages that display the same files. |
|
62 | - * |
|
63 | - * @return string |
|
64 | - * @since 6.0.0 |
|
65 | - */ |
|
66 | - public function getId(); |
|
67 | - |
|
68 | - /** |
|
69 | - * see http://php.net/manual/en/function.mkdir.php |
|
70 | - * implementations need to implement a recursive mkdir |
|
71 | - * |
|
72 | - * @param string $path |
|
73 | - * @return bool |
|
74 | - * @since 6.0.0 |
|
75 | - */ |
|
76 | - public function mkdir($path); |
|
77 | - |
|
78 | - /** |
|
79 | - * see http://php.net/manual/en/function.rmdir.php |
|
80 | - * |
|
81 | - * @param string $path |
|
82 | - * @return bool |
|
83 | - * @since 6.0.0 |
|
84 | - */ |
|
85 | - public function rmdir($path); |
|
86 | - |
|
87 | - /** |
|
88 | - * see http://php.net/manual/en/function.opendir.php |
|
89 | - * |
|
90 | - * @param string $path |
|
91 | - * @return resource|false |
|
92 | - * @since 6.0.0 |
|
93 | - */ |
|
94 | - public function opendir($path); |
|
95 | - |
|
96 | - /** |
|
97 | - * see http://php.net/manual/en/function.is-dir.php |
|
98 | - * |
|
99 | - * @param string $path |
|
100 | - * @return bool |
|
101 | - * @since 6.0.0 |
|
102 | - */ |
|
103 | - public function is_dir($path); |
|
104 | - |
|
105 | - /** |
|
106 | - * see http://php.net/manual/en/function.is-file.php |
|
107 | - * |
|
108 | - * @param string $path |
|
109 | - * @return bool |
|
110 | - * @since 6.0.0 |
|
111 | - */ |
|
112 | - public function is_file($path); |
|
113 | - |
|
114 | - /** |
|
115 | - * see http://php.net/manual/en/function.stat.php |
|
116 | - * only the following keys are required in the result: size and mtime |
|
117 | - * |
|
118 | - * @param string $path |
|
119 | - * @return array|false |
|
120 | - * @since 6.0.0 |
|
121 | - */ |
|
122 | - public function stat($path); |
|
123 | - |
|
124 | - /** |
|
125 | - * see http://php.net/manual/en/function.filetype.php |
|
126 | - * |
|
127 | - * @param string $path |
|
128 | - * @return string|false |
|
129 | - * @since 6.0.0 |
|
130 | - */ |
|
131 | - public function filetype($path); |
|
132 | - |
|
133 | - /** |
|
134 | - * see http://php.net/manual/en/function.filesize.php |
|
135 | - * The result for filesize when called on a folder is required to be 0 |
|
136 | - * |
|
137 | - * @param string $path |
|
138 | - * @return int|false |
|
139 | - * @since 6.0.0 |
|
140 | - */ |
|
141 | - public function filesize($path); |
|
142 | - |
|
143 | - /** |
|
144 | - * check if a file can be created in $path |
|
145 | - * |
|
146 | - * @param string $path |
|
147 | - * @return bool |
|
148 | - * @since 6.0.0 |
|
149 | - */ |
|
150 | - public function isCreatable($path); |
|
151 | - |
|
152 | - /** |
|
153 | - * check if a file can be read |
|
154 | - * |
|
155 | - * @param string $path |
|
156 | - * @return bool |
|
157 | - * @since 6.0.0 |
|
158 | - */ |
|
159 | - public function isReadable($path); |
|
160 | - |
|
161 | - /** |
|
162 | - * check if a file can be written to |
|
163 | - * |
|
164 | - * @param string $path |
|
165 | - * @return bool |
|
166 | - * @since 6.0.0 |
|
167 | - */ |
|
168 | - public function isUpdatable($path); |
|
169 | - |
|
170 | - /** |
|
171 | - * check if a file can be deleted |
|
172 | - * |
|
173 | - * @param string $path |
|
174 | - * @return bool |
|
175 | - * @since 6.0.0 |
|
176 | - */ |
|
177 | - public function isDeletable($path); |
|
178 | - |
|
179 | - /** |
|
180 | - * check if a file can be shared |
|
181 | - * |
|
182 | - * @param string $path |
|
183 | - * @return bool |
|
184 | - * @since 6.0.0 |
|
185 | - */ |
|
186 | - public function isSharable($path); |
|
187 | - |
|
188 | - /** |
|
189 | - * get the full permissions of a path. |
|
190 | - * Should return a combination of the PERMISSION_ constants defined in lib/public/constants.php |
|
191 | - * |
|
192 | - * @param string $path |
|
193 | - * @return int |
|
194 | - * @since 6.0.0 |
|
195 | - */ |
|
196 | - public function getPermissions($path); |
|
197 | - |
|
198 | - /** |
|
199 | - * see http://php.net/manual/en/function.file_exists.php |
|
200 | - * |
|
201 | - * @param string $path |
|
202 | - * @return bool |
|
203 | - * @since 6.0.0 |
|
204 | - */ |
|
205 | - public function file_exists($path); |
|
206 | - |
|
207 | - /** |
|
208 | - * see http://php.net/manual/en/function.filemtime.php |
|
209 | - * |
|
210 | - * @param string $path |
|
211 | - * @return int|false |
|
212 | - * @since 6.0.0 |
|
213 | - */ |
|
214 | - public function filemtime($path); |
|
215 | - |
|
216 | - /** |
|
217 | - * see http://php.net/manual/en/function.file_get_contents.php |
|
218 | - * |
|
219 | - * @param string $path |
|
220 | - * @return string|false |
|
221 | - * @since 6.0.0 |
|
222 | - */ |
|
223 | - public function file_get_contents($path); |
|
224 | - |
|
225 | - /** |
|
226 | - * see http://php.net/manual/en/function.file_put_contents.php |
|
227 | - * |
|
228 | - * @param string $path |
|
229 | - * @param string $data |
|
230 | - * @return bool |
|
231 | - * @since 6.0.0 |
|
232 | - */ |
|
233 | - public function file_put_contents($path, $data); |
|
234 | - |
|
235 | - /** |
|
236 | - * see http://php.net/manual/en/function.unlink.php |
|
237 | - * |
|
238 | - * @param string $path |
|
239 | - * @return bool |
|
240 | - * @since 6.0.0 |
|
241 | - */ |
|
242 | - public function unlink($path); |
|
243 | - |
|
244 | - /** |
|
245 | - * see http://php.net/manual/en/function.rename.php |
|
246 | - * |
|
247 | - * @param string $path1 |
|
248 | - * @param string $path2 |
|
249 | - * @return bool |
|
250 | - * @since 6.0.0 |
|
251 | - */ |
|
252 | - public function rename($path1, $path2); |
|
253 | - |
|
254 | - /** |
|
255 | - * see http://php.net/manual/en/function.copy.php |
|
256 | - * |
|
257 | - * @param string $path1 |
|
258 | - * @param string $path2 |
|
259 | - * @return bool |
|
260 | - * @since 6.0.0 |
|
261 | - */ |
|
262 | - public function copy($path1, $path2); |
|
263 | - |
|
264 | - /** |
|
265 | - * see http://php.net/manual/en/function.fopen.php |
|
266 | - * |
|
267 | - * @param string $path |
|
268 | - * @param string $mode |
|
269 | - * @return resource|false |
|
270 | - * @since 6.0.0 |
|
271 | - */ |
|
272 | - public function fopen($path, $mode); |
|
273 | - |
|
274 | - /** |
|
275 | - * get the mimetype for a file or folder |
|
276 | - * The mimetype for a folder is required to be "httpd/unix-directory" |
|
277 | - * |
|
278 | - * @param string $path |
|
279 | - * @return string|false |
|
280 | - * @since 6.0.0 |
|
281 | - */ |
|
282 | - public function getMimeType($path); |
|
283 | - |
|
284 | - /** |
|
285 | - * see http://php.net/manual/en/function.hash-file.php |
|
286 | - * |
|
287 | - * @param string $type |
|
288 | - * @param string $path |
|
289 | - * @param bool $raw |
|
290 | - * @return string|false |
|
291 | - * @since 6.0.0 |
|
292 | - */ |
|
293 | - public function hash($type, $path, $raw = false); |
|
294 | - |
|
295 | - /** |
|
296 | - * see http://php.net/manual/en/function.free_space.php |
|
297 | - * |
|
298 | - * @param string $path |
|
299 | - * @return int|false |
|
300 | - * @since 6.0.0 |
|
301 | - */ |
|
302 | - public function free_space($path); |
|
303 | - |
|
304 | - /** |
|
305 | - * search for occurrences of $query in file names |
|
306 | - * |
|
307 | - * @param string $query |
|
308 | - * @return array|false |
|
309 | - * @since 6.0.0 |
|
310 | - */ |
|
311 | - public function search($query); |
|
312 | - |
|
313 | - /** |
|
314 | - * see http://php.net/manual/en/function.touch.php |
|
315 | - * If the backend does not support the operation, false should be returned |
|
316 | - * |
|
317 | - * @param string $path |
|
318 | - * @param int $mtime |
|
319 | - * @return bool |
|
320 | - * @since 6.0.0 |
|
321 | - */ |
|
322 | - public function touch($path, $mtime = null); |
|
323 | - |
|
324 | - /** |
|
325 | - * get the path to a local version of the file. |
|
326 | - * The local version of the file can be temporary and doesn't have to be persistent across requests |
|
327 | - * |
|
328 | - * @param string $path |
|
329 | - * @return string|false |
|
330 | - * @since 6.0.0 |
|
331 | - */ |
|
332 | - public function getLocalFile($path); |
|
333 | - |
|
334 | - /** |
|
335 | - * check if a file or folder has been updated since $time |
|
336 | - * |
|
337 | - * @param string $path |
|
338 | - * @param int $time |
|
339 | - * @return bool |
|
340 | - * @since 6.0.0 |
|
341 | - * |
|
342 | - * hasUpdated for folders should return at least true if a file inside the folder is add, removed or renamed. |
|
343 | - * returning true for other changes in the folder is optional |
|
344 | - */ |
|
345 | - public function hasUpdated($path, $time); |
|
346 | - |
|
347 | - /** |
|
348 | - * get the ETag for a file or folder |
|
349 | - * |
|
350 | - * @param string $path |
|
351 | - * @return string|false |
|
352 | - * @since 6.0.0 |
|
353 | - */ |
|
354 | - public function getETag($path); |
|
355 | - |
|
356 | - /** |
|
357 | - * Returns whether the storage is local, which means that files |
|
358 | - * are stored on the local filesystem instead of remotely. |
|
359 | - * Calling getLocalFile() for local storages should always |
|
360 | - * return the local files, whereas for non-local storages |
|
361 | - * it might return a temporary file. |
|
362 | - * |
|
363 | - * @return bool true if the files are stored locally, false otherwise |
|
364 | - * @since 7.0.0 |
|
365 | - */ |
|
366 | - public function isLocal(); |
|
367 | - |
|
368 | - /** |
|
369 | - * Check if the storage is an instance of $class or is a wrapper for a storage that is an instance of $class |
|
370 | - * |
|
371 | - * @param string $class |
|
372 | - * @return bool |
|
373 | - * @since 7.0.0 |
|
374 | - */ |
|
375 | - public function instanceOfStorage($class); |
|
376 | - |
|
377 | - /** |
|
378 | - * A custom storage implementation can return an url for direct download of a give file. |
|
379 | - * |
|
380 | - * For now the returned array can hold the parameter url - in future more attributes might follow. |
|
381 | - * |
|
382 | - * @param string $path |
|
383 | - * @return array|false |
|
384 | - * @since 8.0.0 |
|
385 | - */ |
|
386 | - public function getDirectDownload($path); |
|
387 | - |
|
388 | - /** |
|
389 | - * @param string $path the path of the target folder |
|
390 | - * @param string $fileName the name of the file itself |
|
391 | - * @return void |
|
392 | - * @throws InvalidPathException |
|
393 | - * @since 8.1.0 |
|
394 | - */ |
|
395 | - public function verifyPath($path, $fileName); |
|
396 | - |
|
397 | - /** |
|
398 | - * @param IStorage $sourceStorage |
|
399 | - * @param string $sourceInternalPath |
|
400 | - * @param string $targetInternalPath |
|
401 | - * @return bool |
|
402 | - * @since 8.1.0 |
|
403 | - */ |
|
404 | - public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath); |
|
405 | - |
|
406 | - /** |
|
407 | - * @param IStorage $sourceStorage |
|
408 | - * @param string $sourceInternalPath |
|
409 | - * @param string $targetInternalPath |
|
410 | - * @return bool |
|
411 | - * @since 8.1.0 |
|
412 | - */ |
|
413 | - public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath); |
|
414 | - |
|
415 | - /** |
|
416 | - * @param string $path The path of the file to acquire the lock for |
|
417 | - * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE |
|
418 | - * @param \OCP\Lock\ILockingProvider $provider |
|
419 | - * @throws \OCP\Lock\LockedException |
|
420 | - * @since 8.1.0 |
|
421 | - */ |
|
422 | - public function acquireLock($path, $type, ILockingProvider $provider); |
|
423 | - |
|
424 | - /** |
|
425 | - * @param string $path The path of the file to acquire the lock for |
|
426 | - * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE |
|
427 | - * @param \OCP\Lock\ILockingProvider $provider |
|
428 | - * @throws \OCP\Lock\LockedException |
|
429 | - * @since 8.1.0 |
|
430 | - */ |
|
431 | - public function releaseLock($path, $type, ILockingProvider $provider); |
|
432 | - |
|
433 | - /** |
|
434 | - * @param string $path The path of the file to change the lock for |
|
435 | - * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE |
|
436 | - * @param \OCP\Lock\ILockingProvider $provider |
|
437 | - * @throws \OCP\Lock\LockedException |
|
438 | - * @since 8.1.0 |
|
439 | - */ |
|
440 | - public function changeLock($path, $type, ILockingProvider $provider); |
|
441 | - |
|
442 | - /** |
|
443 | - * Test a storage for availability |
|
444 | - * |
|
445 | - * @since 8.2.0 |
|
446 | - * @return bool |
|
447 | - */ |
|
448 | - public function test(); |
|
449 | - |
|
450 | - /** |
|
451 | - * @since 8.2.0 |
|
452 | - * @return array [ available, last_checked ] |
|
453 | - */ |
|
454 | - public function getAvailability(); |
|
455 | - |
|
456 | - /** |
|
457 | - * @since 8.2.0 |
|
458 | - * @param bool $isAvailable |
|
459 | - */ |
|
460 | - public function setAvailability($isAvailable); |
|
461 | - |
|
462 | - public function needsPartFile(); |
|
50 | + /** |
|
51 | + * $parameters is a free form array with the configuration options needed to construct the storage |
|
52 | + * |
|
53 | + * @param array $parameters |
|
54 | + * @since 6.0.0 |
|
55 | + */ |
|
56 | + public function __construct($parameters); |
|
57 | + |
|
58 | + /** |
|
59 | + * Get the identifier for the storage, |
|
60 | + * the returned id should be the same for every storage object that is created with the same parameters |
|
61 | + * and two storage objects with the same id should refer to two storages that display the same files. |
|
62 | + * |
|
63 | + * @return string |
|
64 | + * @since 6.0.0 |
|
65 | + */ |
|
66 | + public function getId(); |
|
67 | + |
|
68 | + /** |
|
69 | + * see http://php.net/manual/en/function.mkdir.php |
|
70 | + * implementations need to implement a recursive mkdir |
|
71 | + * |
|
72 | + * @param string $path |
|
73 | + * @return bool |
|
74 | + * @since 6.0.0 |
|
75 | + */ |
|
76 | + public function mkdir($path); |
|
77 | + |
|
78 | + /** |
|
79 | + * see http://php.net/manual/en/function.rmdir.php |
|
80 | + * |
|
81 | + * @param string $path |
|
82 | + * @return bool |
|
83 | + * @since 6.0.0 |
|
84 | + */ |
|
85 | + public function rmdir($path); |
|
86 | + |
|
87 | + /** |
|
88 | + * see http://php.net/manual/en/function.opendir.php |
|
89 | + * |
|
90 | + * @param string $path |
|
91 | + * @return resource|false |
|
92 | + * @since 6.0.0 |
|
93 | + */ |
|
94 | + public function opendir($path); |
|
95 | + |
|
96 | + /** |
|
97 | + * see http://php.net/manual/en/function.is-dir.php |
|
98 | + * |
|
99 | + * @param string $path |
|
100 | + * @return bool |
|
101 | + * @since 6.0.0 |
|
102 | + */ |
|
103 | + public function is_dir($path); |
|
104 | + |
|
105 | + /** |
|
106 | + * see http://php.net/manual/en/function.is-file.php |
|
107 | + * |
|
108 | + * @param string $path |
|
109 | + * @return bool |
|
110 | + * @since 6.0.0 |
|
111 | + */ |
|
112 | + public function is_file($path); |
|
113 | + |
|
114 | + /** |
|
115 | + * see http://php.net/manual/en/function.stat.php |
|
116 | + * only the following keys are required in the result: size and mtime |
|
117 | + * |
|
118 | + * @param string $path |
|
119 | + * @return array|false |
|
120 | + * @since 6.0.0 |
|
121 | + */ |
|
122 | + public function stat($path); |
|
123 | + |
|
124 | + /** |
|
125 | + * see http://php.net/manual/en/function.filetype.php |
|
126 | + * |
|
127 | + * @param string $path |
|
128 | + * @return string|false |
|
129 | + * @since 6.0.0 |
|
130 | + */ |
|
131 | + public function filetype($path); |
|
132 | + |
|
133 | + /** |
|
134 | + * see http://php.net/manual/en/function.filesize.php |
|
135 | + * The result for filesize when called on a folder is required to be 0 |
|
136 | + * |
|
137 | + * @param string $path |
|
138 | + * @return int|false |
|
139 | + * @since 6.0.0 |
|
140 | + */ |
|
141 | + public function filesize($path); |
|
142 | + |
|
143 | + /** |
|
144 | + * check if a file can be created in $path |
|
145 | + * |
|
146 | + * @param string $path |
|
147 | + * @return bool |
|
148 | + * @since 6.0.0 |
|
149 | + */ |
|
150 | + public function isCreatable($path); |
|
151 | + |
|
152 | + /** |
|
153 | + * check if a file can be read |
|
154 | + * |
|
155 | + * @param string $path |
|
156 | + * @return bool |
|
157 | + * @since 6.0.0 |
|
158 | + */ |
|
159 | + public function isReadable($path); |
|
160 | + |
|
161 | + /** |
|
162 | + * check if a file can be written to |
|
163 | + * |
|
164 | + * @param string $path |
|
165 | + * @return bool |
|
166 | + * @since 6.0.0 |
|
167 | + */ |
|
168 | + public function isUpdatable($path); |
|
169 | + |
|
170 | + /** |
|
171 | + * check if a file can be deleted |
|
172 | + * |
|
173 | + * @param string $path |
|
174 | + * @return bool |
|
175 | + * @since 6.0.0 |
|
176 | + */ |
|
177 | + public function isDeletable($path); |
|
178 | + |
|
179 | + /** |
|
180 | + * check if a file can be shared |
|
181 | + * |
|
182 | + * @param string $path |
|
183 | + * @return bool |
|
184 | + * @since 6.0.0 |
|
185 | + */ |
|
186 | + public function isSharable($path); |
|
187 | + |
|
188 | + /** |
|
189 | + * get the full permissions of a path. |
|
190 | + * Should return a combination of the PERMISSION_ constants defined in lib/public/constants.php |
|
191 | + * |
|
192 | + * @param string $path |
|
193 | + * @return int |
|
194 | + * @since 6.0.0 |
|
195 | + */ |
|
196 | + public function getPermissions($path); |
|
197 | + |
|
198 | + /** |
|
199 | + * see http://php.net/manual/en/function.file_exists.php |
|
200 | + * |
|
201 | + * @param string $path |
|
202 | + * @return bool |
|
203 | + * @since 6.0.0 |
|
204 | + */ |
|
205 | + public function file_exists($path); |
|
206 | + |
|
207 | + /** |
|
208 | + * see http://php.net/manual/en/function.filemtime.php |
|
209 | + * |
|
210 | + * @param string $path |
|
211 | + * @return int|false |
|
212 | + * @since 6.0.0 |
|
213 | + */ |
|
214 | + public function filemtime($path); |
|
215 | + |
|
216 | + /** |
|
217 | + * see http://php.net/manual/en/function.file_get_contents.php |
|
218 | + * |
|
219 | + * @param string $path |
|
220 | + * @return string|false |
|
221 | + * @since 6.0.0 |
|
222 | + */ |
|
223 | + public function file_get_contents($path); |
|
224 | + |
|
225 | + /** |
|
226 | + * see http://php.net/manual/en/function.file_put_contents.php |
|
227 | + * |
|
228 | + * @param string $path |
|
229 | + * @param string $data |
|
230 | + * @return bool |
|
231 | + * @since 6.0.0 |
|
232 | + */ |
|
233 | + public function file_put_contents($path, $data); |
|
234 | + |
|
235 | + /** |
|
236 | + * see http://php.net/manual/en/function.unlink.php |
|
237 | + * |
|
238 | + * @param string $path |
|
239 | + * @return bool |
|
240 | + * @since 6.0.0 |
|
241 | + */ |
|
242 | + public function unlink($path); |
|
243 | + |
|
244 | + /** |
|
245 | + * see http://php.net/manual/en/function.rename.php |
|
246 | + * |
|
247 | + * @param string $path1 |
|
248 | + * @param string $path2 |
|
249 | + * @return bool |
|
250 | + * @since 6.0.0 |
|
251 | + */ |
|
252 | + public function rename($path1, $path2); |
|
253 | + |
|
254 | + /** |
|
255 | + * see http://php.net/manual/en/function.copy.php |
|
256 | + * |
|
257 | + * @param string $path1 |
|
258 | + * @param string $path2 |
|
259 | + * @return bool |
|
260 | + * @since 6.0.0 |
|
261 | + */ |
|
262 | + public function copy($path1, $path2); |
|
263 | + |
|
264 | + /** |
|
265 | + * see http://php.net/manual/en/function.fopen.php |
|
266 | + * |
|
267 | + * @param string $path |
|
268 | + * @param string $mode |
|
269 | + * @return resource|false |
|
270 | + * @since 6.0.0 |
|
271 | + */ |
|
272 | + public function fopen($path, $mode); |
|
273 | + |
|
274 | + /** |
|
275 | + * get the mimetype for a file or folder |
|
276 | + * The mimetype for a folder is required to be "httpd/unix-directory" |
|
277 | + * |
|
278 | + * @param string $path |
|
279 | + * @return string|false |
|
280 | + * @since 6.0.0 |
|
281 | + */ |
|
282 | + public function getMimeType($path); |
|
283 | + |
|
284 | + /** |
|
285 | + * see http://php.net/manual/en/function.hash-file.php |
|
286 | + * |
|
287 | + * @param string $type |
|
288 | + * @param string $path |
|
289 | + * @param bool $raw |
|
290 | + * @return string|false |
|
291 | + * @since 6.0.0 |
|
292 | + */ |
|
293 | + public function hash($type, $path, $raw = false); |
|
294 | + |
|
295 | + /** |
|
296 | + * see http://php.net/manual/en/function.free_space.php |
|
297 | + * |
|
298 | + * @param string $path |
|
299 | + * @return int|false |
|
300 | + * @since 6.0.0 |
|
301 | + */ |
|
302 | + public function free_space($path); |
|
303 | + |
|
304 | + /** |
|
305 | + * search for occurrences of $query in file names |
|
306 | + * |
|
307 | + * @param string $query |
|
308 | + * @return array|false |
|
309 | + * @since 6.0.0 |
|
310 | + */ |
|
311 | + public function search($query); |
|
312 | + |
|
313 | + /** |
|
314 | + * see http://php.net/manual/en/function.touch.php |
|
315 | + * If the backend does not support the operation, false should be returned |
|
316 | + * |
|
317 | + * @param string $path |
|
318 | + * @param int $mtime |
|
319 | + * @return bool |
|
320 | + * @since 6.0.0 |
|
321 | + */ |
|
322 | + public function touch($path, $mtime = null); |
|
323 | + |
|
324 | + /** |
|
325 | + * get the path to a local version of the file. |
|
326 | + * The local version of the file can be temporary and doesn't have to be persistent across requests |
|
327 | + * |
|
328 | + * @param string $path |
|
329 | + * @return string|false |
|
330 | + * @since 6.0.0 |
|
331 | + */ |
|
332 | + public function getLocalFile($path); |
|
333 | + |
|
334 | + /** |
|
335 | + * check if a file or folder has been updated since $time |
|
336 | + * |
|
337 | + * @param string $path |
|
338 | + * @param int $time |
|
339 | + * @return bool |
|
340 | + * @since 6.0.0 |
|
341 | + * |
|
342 | + * hasUpdated for folders should return at least true if a file inside the folder is add, removed or renamed. |
|
343 | + * returning true for other changes in the folder is optional |
|
344 | + */ |
|
345 | + public function hasUpdated($path, $time); |
|
346 | + |
|
347 | + /** |
|
348 | + * get the ETag for a file or folder |
|
349 | + * |
|
350 | + * @param string $path |
|
351 | + * @return string|false |
|
352 | + * @since 6.0.0 |
|
353 | + */ |
|
354 | + public function getETag($path); |
|
355 | + |
|
356 | + /** |
|
357 | + * Returns whether the storage is local, which means that files |
|
358 | + * are stored on the local filesystem instead of remotely. |
|
359 | + * Calling getLocalFile() for local storages should always |
|
360 | + * return the local files, whereas for non-local storages |
|
361 | + * it might return a temporary file. |
|
362 | + * |
|
363 | + * @return bool true if the files are stored locally, false otherwise |
|
364 | + * @since 7.0.0 |
|
365 | + */ |
|
366 | + public function isLocal(); |
|
367 | + |
|
368 | + /** |
|
369 | + * Check if the storage is an instance of $class or is a wrapper for a storage that is an instance of $class |
|
370 | + * |
|
371 | + * @param string $class |
|
372 | + * @return bool |
|
373 | + * @since 7.0.0 |
|
374 | + */ |
|
375 | + public function instanceOfStorage($class); |
|
376 | + |
|
377 | + /** |
|
378 | + * A custom storage implementation can return an url for direct download of a give file. |
|
379 | + * |
|
380 | + * For now the returned array can hold the parameter url - in future more attributes might follow. |
|
381 | + * |
|
382 | + * @param string $path |
|
383 | + * @return array|false |
|
384 | + * @since 8.0.0 |
|
385 | + */ |
|
386 | + public function getDirectDownload($path); |
|
387 | + |
|
388 | + /** |
|
389 | + * @param string $path the path of the target folder |
|
390 | + * @param string $fileName the name of the file itself |
|
391 | + * @return void |
|
392 | + * @throws InvalidPathException |
|
393 | + * @since 8.1.0 |
|
394 | + */ |
|
395 | + public function verifyPath($path, $fileName); |
|
396 | + |
|
397 | + /** |
|
398 | + * @param IStorage $sourceStorage |
|
399 | + * @param string $sourceInternalPath |
|
400 | + * @param string $targetInternalPath |
|
401 | + * @return bool |
|
402 | + * @since 8.1.0 |
|
403 | + */ |
|
404 | + public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath); |
|
405 | + |
|
406 | + /** |
|
407 | + * @param IStorage $sourceStorage |
|
408 | + * @param string $sourceInternalPath |
|
409 | + * @param string $targetInternalPath |
|
410 | + * @return bool |
|
411 | + * @since 8.1.0 |
|
412 | + */ |
|
413 | + public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath); |
|
414 | + |
|
415 | + /** |
|
416 | + * @param string $path The path of the file to acquire the lock for |
|
417 | + * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE |
|
418 | + * @param \OCP\Lock\ILockingProvider $provider |
|
419 | + * @throws \OCP\Lock\LockedException |
|
420 | + * @since 8.1.0 |
|
421 | + */ |
|
422 | + public function acquireLock($path, $type, ILockingProvider $provider); |
|
423 | + |
|
424 | + /** |
|
425 | + * @param string $path The path of the file to acquire the lock for |
|
426 | + * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE |
|
427 | + * @param \OCP\Lock\ILockingProvider $provider |
|
428 | + * @throws \OCP\Lock\LockedException |
|
429 | + * @since 8.1.0 |
|
430 | + */ |
|
431 | + public function releaseLock($path, $type, ILockingProvider $provider); |
|
432 | + |
|
433 | + /** |
|
434 | + * @param string $path The path of the file to change the lock for |
|
435 | + * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE |
|
436 | + * @param \OCP\Lock\ILockingProvider $provider |
|
437 | + * @throws \OCP\Lock\LockedException |
|
438 | + * @since 8.1.0 |
|
439 | + */ |
|
440 | + public function changeLock($path, $type, ILockingProvider $provider); |
|
441 | + |
|
442 | + /** |
|
443 | + * Test a storage for availability |
|
444 | + * |
|
445 | + * @since 8.2.0 |
|
446 | + * @return bool |
|
447 | + */ |
|
448 | + public function test(); |
|
449 | + |
|
450 | + /** |
|
451 | + * @since 8.2.0 |
|
452 | + * @return array [ available, last_checked ] |
|
453 | + */ |
|
454 | + public function getAvailability(); |
|
455 | + |
|
456 | + /** |
|
457 | + * @since 8.2.0 |
|
458 | + * @param bool $isAvailable |
|
459 | + */ |
|
460 | + public function setAvailability($isAvailable); |
|
461 | + |
|
462 | + public function needsPartFile(); |
|
463 | 463 | } |