@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * http://%host/%context/remote.php/webdav/%root |
33 | 33 | * |
34 | 34 | */ |
35 | -class OwnCloud extends \OC\Files\Storage\DAV{ |
|
35 | +class OwnCloud extends \OC\Files\Storage\DAV { |
|
36 | 36 | const OC_URL_SUFFIX = 'remote.php/webdav'; |
37 | 37 | |
38 | 38 | public function __construct($params) { |
@@ -49,27 +49,27 @@ discard block |
||
49 | 49 | } |
50 | 50 | $contextPath = ''; |
51 | 51 | $hostSlashPos = strpos($host, '/'); |
52 | - if ($hostSlashPos !== false){ |
|
52 | + if ($hostSlashPos !== false) { |
|
53 | 53 | $contextPath = substr($host, $hostSlashPos); |
54 | 54 | $host = substr($host, 0, $hostSlashPos); |
55 | 55 | } |
56 | 56 | |
57 | - if (substr($contextPath, -1) !== '/'){ |
|
57 | + if (substr($contextPath, -1) !== '/') { |
|
58 | 58 | $contextPath .= '/'; |
59 | 59 | } |
60 | 60 | |
61 | - if (isset($params['root'])){ |
|
61 | + if (isset($params['root'])) { |
|
62 | 62 | $root = $params['root']; |
63 | - if (substr($root, 0, 1) !== '/'){ |
|
64 | - $root = '/' . $root; |
|
63 | + if (substr($root, 0, 1) !== '/') { |
|
64 | + $root = '/'.$root; |
|
65 | 65 | } |
66 | 66 | } |
67 | - else{ |
|
67 | + else { |
|
68 | 68 | $root = '/'; |
69 | 69 | } |
70 | 70 | |
71 | 71 | $params['host'] = $host; |
72 | - $params['root'] = $contextPath . self::OC_URL_SUFFIX . $root; |
|
72 | + $params['root'] = $contextPath.self::OC_URL_SUFFIX.$root; |
|
73 | 73 | $params['authType'] = Client::AUTH_BASIC; |
74 | 74 | |
75 | 75 | parent::__construct($params); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | if (is_string($params['secure'])) { |
105 | 105 | $this->secure = ($params['secure'] === 'true'); |
106 | 106 | } else { |
107 | - $this->secure = (bool)$params['secure']; |
|
107 | + $this->secure = (bool) $params['secure']; |
|
108 | 108 | } |
109 | 109 | } else { |
110 | 110 | $this->secure = false; |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | } |
123 | 123 | $this->root = isset($params['root']) ? $params['root'] : '/'; |
124 | 124 | if (!$this->root || $this->root[0] != '/') { |
125 | - $this->root = '/' . $this->root; |
|
125 | + $this->root = '/'.$this->root; |
|
126 | 126 | } |
127 | 127 | if (substr($this->root, -1, 1) != '/') { |
128 | 128 | $this->root .= '/'; |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | } |
149 | 149 | |
150 | 150 | $proxy = \OC::$server->getConfig()->getSystemValue('proxy', ''); |
151 | - if($proxy !== '') { |
|
151 | + if ($proxy !== '') { |
|
152 | 152 | $settings['proxy'] = $proxy; |
153 | 153 | } |
154 | 154 | |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | |
169 | 169 | /** {@inheritdoc} */ |
170 | 170 | public function getId() { |
171 | - return 'webdav::' . $this->user . '@' . $this->host . '/' . $this->root; |
|
171 | + return 'webdav::'.$this->user.'@'.$this->host.'/'.$this->root; |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** {@inheritdoc} */ |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | if ($this->secure) { |
178 | 178 | $baseUri .= 's'; |
179 | 179 | } |
180 | - $baseUri .= '://' . $this->host . $this->root; |
|
180 | + $baseUri .= '://'.$this->host.$this->root; |
|
181 | 181 | return $baseUri; |
182 | 182 | } |
183 | 183 | |
@@ -198,8 +198,8 @@ discard block |
||
198 | 198 | $path = $this->cleanPath($path); |
199 | 199 | // FIXME: some WebDAV impl return 403 when trying to DELETE |
200 | 200 | // a non-empty folder |
201 | - $result = $this->simpleResponse('DELETE', $path . '/', null, 204); |
|
202 | - $this->statCache->clear($path . '/'); |
|
201 | + $result = $this->simpleResponse('DELETE', $path.'/', null, 204); |
|
202 | + $this->statCache->clear($path.'/'); |
|
203 | 203 | $this->statCache->remove($path); |
204 | 204 | return $result; |
205 | 205 | } |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | $this->statCache->set($path, $response); |
275 | 275 | } catch (ClientHttpException $e) { |
276 | 276 | if ($e->getHttpStatus() === 404) { |
277 | - $this->statCache->clear($path . '/'); |
|
277 | + $this->statCache->clear($path.'/'); |
|
278 | 278 | $this->statCache->set($path, false); |
279 | 279 | return false; |
280 | 280 | } |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | $this->init(); |
332 | 332 | $path = $this->cleanPath($path); |
333 | 333 | $result = $this->simpleResponse('DELETE', $path, null, 204); |
334 | - $this->statCache->clear($path . '/'); |
|
334 | + $this->statCache->clear($path.'/'); |
|
335 | 335 | $this->statCache->remove($path); |
336 | 336 | return $result; |
337 | 337 | } |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | try { |
347 | 347 | $response = $this->httpClientService |
348 | 348 | ->newClient() |
349 | - ->get($this->createBaseUri() . $this->encodePath($path), [ |
|
349 | + ->get($this->createBaseUri().$this->encodePath($path), [ |
|
350 | 350 | 'auth' => [$this->user, $this->password], |
351 | 351 | 'stream' => true |
352 | 352 | ]); |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | if ($response->getStatusCode() === Http::STATUS_LOCKED) { |
364 | 364 | throw new \OCP\Lock\LockedException($path); |
365 | 365 | } else { |
366 | - Util::writeLog("webdav client", 'Guzzle get returned status code ' . $response->getStatusCode(), Util::ERROR); |
|
366 | + Util::writeLog("webdav client", 'Guzzle get returned status code '.$response->getStatusCode(), Util::ERROR); |
|
367 | 367 | } |
368 | 368 | } |
369 | 369 | |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | $tmpFile = $tempManager->getTemporaryFile($ext); |
404 | 404 | } |
405 | 405 | $handle = fopen($tmpFile, $mode); |
406 | - return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) { |
|
406 | + return CallbackWrapper::wrap($handle, null, null, function() use ($path, $tmpFile) { |
|
407 | 407 | $this->writeBack($tmpFile, $path); |
408 | 408 | }); |
409 | 409 | } |
@@ -428,7 +428,7 @@ discard block |
||
428 | 428 | return FileInfo::SPACE_UNKNOWN; |
429 | 429 | } |
430 | 430 | if (isset($response['{DAV:}quota-available-bytes'])) { |
431 | - return (int)$response['{DAV:}quota-available-bytes']; |
|
431 | + return (int) $response['{DAV:}quota-available-bytes']; |
|
432 | 432 | } else { |
433 | 433 | return FileInfo::SPACE_UNKNOWN; |
434 | 434 | } |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | |
505 | 505 | $this->httpClientService |
506 | 506 | ->newClient() |
507 | - ->put($this->createBaseUri() . $this->encodePath($target), [ |
|
507 | + ->put($this->createBaseUri().$this->encodePath($target), [ |
|
508 | 508 | 'body' => $source, |
509 | 509 | 'auth' => [$this->user, $this->password] |
510 | 510 | ]); |
@@ -521,18 +521,18 @@ discard block |
||
521 | 521 | // overwrite directory ? |
522 | 522 | if ($this->is_dir($path2)) { |
523 | 523 | // needs trailing slash in destination |
524 | - $path2 = rtrim($path2, '/') . '/'; |
|
524 | + $path2 = rtrim($path2, '/').'/'; |
|
525 | 525 | } |
526 | 526 | $this->client->request( |
527 | 527 | 'MOVE', |
528 | 528 | $this->encodePath($path1), |
529 | 529 | null, |
530 | 530 | [ |
531 | - 'Destination' => $this->createBaseUri() . $this->encodePath($path2), |
|
531 | + 'Destination' => $this->createBaseUri().$this->encodePath($path2), |
|
532 | 532 | ] |
533 | 533 | ); |
534 | - $this->statCache->clear($path1 . '/'); |
|
535 | - $this->statCache->clear($path2 . '/'); |
|
534 | + $this->statCache->clear($path1.'/'); |
|
535 | + $this->statCache->clear($path2.'/'); |
|
536 | 536 | $this->statCache->set($path1, false); |
537 | 537 | $this->statCache->set($path2, true); |
538 | 538 | $this->removeCachedFile($path1); |
@@ -553,17 +553,17 @@ discard block |
||
553 | 553 | // overwrite directory ? |
554 | 554 | if ($this->is_dir($path2)) { |
555 | 555 | // needs trailing slash in destination |
556 | - $path2 = rtrim($path2, '/') . '/'; |
|
556 | + $path2 = rtrim($path2, '/').'/'; |
|
557 | 557 | } |
558 | 558 | $this->client->request( |
559 | 559 | 'COPY', |
560 | 560 | $this->encodePath($path1), |
561 | 561 | null, |
562 | 562 | [ |
563 | - 'Destination' => $this->createBaseUri() . $this->encodePath($path2), |
|
563 | + 'Destination' => $this->createBaseUri().$this->encodePath($path2), |
|
564 | 564 | ] |
565 | 565 | ); |
566 | - $this->statCache->clear($path2 . '/'); |
|
566 | + $this->statCache->clear($path2.'/'); |
|
567 | 567 | $this->statCache->set($path2, true); |
568 | 568 | $this->removeCachedFile($path2); |
569 | 569 | return true; |
@@ -582,7 +582,7 @@ discard block |
||
582 | 582 | } |
583 | 583 | return [ |
584 | 584 | 'mtime' => strtotime($response['{DAV:}getlastmodified']), |
585 | - 'size' => (int)isset($response['{DAV:}getcontentlength']) ? $response['{DAV:}getcontentlength'] : 0, |
|
585 | + 'size' => (int) isset($response['{DAV:}getcontentlength']) ? $response['{DAV:}getcontentlength'] : 0, |
|
586 | 586 | ]; |
587 | 587 | } catch (\Exception $e) { |
588 | 588 | $this->convertException($e, $path); |
@@ -656,7 +656,7 @@ discard block |
||
656 | 656 | return $response['statusCode'] == $expected; |
657 | 657 | } catch (ClientHttpException $e) { |
658 | 658 | if ($e->getHttpStatus() === 404 && $method === 'DELETE') { |
659 | - $this->statCache->clear($path . '/'); |
|
659 | + $this->statCache->clear($path.'/'); |
|
660 | 660 | $this->statCache->set($path, false); |
661 | 661 | return false; |
662 | 662 | } |
@@ -677,22 +677,22 @@ discard block |
||
677 | 677 | |
678 | 678 | /** {@inheritdoc} */ |
679 | 679 | public function isUpdatable($path) { |
680 | - return (bool)($this->getPermissions($path) & Constants::PERMISSION_UPDATE); |
|
680 | + return (bool) ($this->getPermissions($path) & Constants::PERMISSION_UPDATE); |
|
681 | 681 | } |
682 | 682 | |
683 | 683 | /** {@inheritdoc} */ |
684 | 684 | public function isCreatable($path) { |
685 | - return (bool)($this->getPermissions($path) & Constants::PERMISSION_CREATE); |
|
685 | + return (bool) ($this->getPermissions($path) & Constants::PERMISSION_CREATE); |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | /** {@inheritdoc} */ |
689 | 689 | public function isSharable($path) { |
690 | - return (bool)($this->getPermissions($path) & Constants::PERMISSION_SHARE); |
|
690 | + return (bool) ($this->getPermissions($path) & Constants::PERMISSION_SHARE); |
|
691 | 691 | } |
692 | 692 | |
693 | 693 | /** {@inheritdoc} */ |
694 | 694 | public function isDeletable($path) { |
695 | - return (bool)($this->getPermissions($path) & Constants::PERMISSION_DELETE); |
|
695 | + return (bool) ($this->getPermissions($path) & Constants::PERMISSION_DELETE); |
|
696 | 696 | } |
697 | 697 | |
698 | 698 | /** {@inheritdoc} */ |
@@ -768,7 +768,7 @@ discard block |
||
768 | 768 | if ($response === false) { |
769 | 769 | if ($path === '') { |
770 | 770 | // if root is gone it means the storage is not available |
771 | - throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage()); |
|
771 | + throw new StorageNotAvailableException(get_class($e).': '.$e->getMessage()); |
|
772 | 772 | } |
773 | 773 | return false; |
774 | 774 | } |
@@ -781,7 +781,7 @@ discard block |
||
781 | 781 | if (!empty($etag) && $cachedData['etag'] !== $etag) { |
782 | 782 | return true; |
783 | 783 | } else if (isset($response['{http://open-collaboration-services.org/ns}share-permissions'])) { |
784 | - $sharePermissions = (int)$response['{http://open-collaboration-services.org/ns}share-permissions']; |
|
784 | + $sharePermissions = (int) $response['{http://open-collaboration-services.org/ns}share-permissions']; |
|
785 | 785 | return $sharePermissions !== $cachedData['permissions']; |
786 | 786 | } else if (isset($response['{http://owncloud.org/ns}permissions'])) { |
787 | 787 | $permissions = $this->parsePermissions($response['{http://owncloud.org/ns}permissions']); |
@@ -797,7 +797,7 @@ discard block |
||
797 | 797 | if ($e->getHttpStatus() === 405) { |
798 | 798 | if ($path === '') { |
799 | 799 | // if root is gone it means the storage is not available |
800 | - throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage()); |
|
800 | + throw new StorageNotAvailableException(get_class($e).': '.$e->getMessage()); |
|
801 | 801 | } |
802 | 802 | return false; |
803 | 803 | } |
@@ -832,19 +832,19 @@ discard block |
||
832 | 832 | } |
833 | 833 | if ($e->getHttpStatus() === Http::STATUS_UNAUTHORIZED) { |
834 | 834 | // either password was changed or was invalid all along |
835 | - throw new StorageInvalidException(get_class($e) . ': ' . $e->getMessage()); |
|
835 | + throw new StorageInvalidException(get_class($e).': '.$e->getMessage()); |
|
836 | 836 | } else if ($e->getHttpStatus() === Http::STATUS_METHOD_NOT_ALLOWED) { |
837 | 837 | // ignore exception for MethodNotAllowed, false will be returned |
838 | 838 | return; |
839 | 839 | } |
840 | - throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage()); |
|
840 | + throw new StorageNotAvailableException(get_class($e).': '.$e->getMessage()); |
|
841 | 841 | } else if ($e instanceof ClientException) { |
842 | 842 | // connection timeout or refused, server could be temporarily down |
843 | - throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage()); |
|
843 | + throw new StorageNotAvailableException(get_class($e).': '.$e->getMessage()); |
|
844 | 844 | } else if ($e instanceof \InvalidArgumentException) { |
845 | 845 | // parse error because the server returned HTML instead of XML, |
846 | 846 | // possibly temporarily down |
847 | - throw new StorageNotAvailableException(get_class($e) . ': ' . $e->getMessage()); |
|
847 | + throw new StorageNotAvailableException(get_class($e).': '.$e->getMessage()); |
|
848 | 848 | } else if (($e instanceof StorageNotAvailableException) || ($e instanceof StorageInvalidException)) { |
849 | 849 | // rethrow |
850 | 850 | throw $e; |