@@ -370,18 +370,18 @@ discard block |
||
370 | 370 | private function findFileWithExtension($class, $ext) |
371 | 371 | { |
372 | 372 | // PSR-4 lookup |
373 | - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
|
373 | + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR).$ext; |
|
374 | 374 | |
375 | 375 | $first = $class[0]; |
376 | 376 | if (isset($this->prefixLengthsPsr4[$first])) { |
377 | 377 | $subPath = $class; |
378 | 378 | while (false !== $lastPos = strrpos($subPath, '\\')) { |
379 | 379 | $subPath = substr($subPath, 0, $lastPos); |
380 | - $search = $subPath . '\\'; |
|
380 | + $search = $subPath.'\\'; |
|
381 | 381 | if (isset($this->prefixDirsPsr4[$search])) { |
382 | - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); |
|
382 | + $pathEnd = DIRECTORY_SEPARATOR.substr($logicalPathPsr4, $lastPos + 1); |
|
383 | 383 | foreach ($this->prefixDirsPsr4[$search] as $dir) { |
384 | - if (file_exists($file = $dir . $pathEnd)) { |
|
384 | + if (file_exists($file = $dir.$pathEnd)) { |
|
385 | 385 | return $file; |
386 | 386 | } |
387 | 387 | } |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | |
392 | 392 | // PSR-4 fallback dirs |
393 | 393 | foreach ($this->fallbackDirsPsr4 as $dir) { |
394 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
394 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr4)) { |
|
395 | 395 | return $file; |
396 | 396 | } |
397 | 397 | } |
@@ -403,14 +403,14 @@ discard block |
||
403 | 403 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
404 | 404 | } else { |
405 | 405 | // PEAR-like class name |
406 | - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
|
406 | + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR).$ext; |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | if (isset($this->prefixesPsr0[$first])) { |
410 | 410 | foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { |
411 | 411 | if (0 === strpos($class, $prefix)) { |
412 | 412 | foreach ($dirs as $dir) { |
413 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
413 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
414 | 414 | return $file; |
415 | 415 | } |
416 | 416 | } |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | |
421 | 421 | // PSR-0 fallback dirs |
422 | 422 | foreach ($this->fallbackDirsPsr0 as $dir) { |
423 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
423 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
424 | 424 | return $file; |
425 | 425 | } |
426 | 426 | } |
@@ -370,18 +370,18 @@ discard block |
||
370 | 370 | private function findFileWithExtension($class, $ext) |
371 | 371 | { |
372 | 372 | // PSR-4 lookup |
373 | - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
|
373 | + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR).$ext; |
|
374 | 374 | |
375 | 375 | $first = $class[0]; |
376 | 376 | if (isset($this->prefixLengthsPsr4[$first])) { |
377 | 377 | $subPath = $class; |
378 | 378 | while (false !== $lastPos = strrpos($subPath, '\\')) { |
379 | 379 | $subPath = substr($subPath, 0, $lastPos); |
380 | - $search = $subPath . '\\'; |
|
380 | + $search = $subPath.'\\'; |
|
381 | 381 | if (isset($this->prefixDirsPsr4[$search])) { |
382 | - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); |
|
382 | + $pathEnd = DIRECTORY_SEPARATOR.substr($logicalPathPsr4, $lastPos + 1); |
|
383 | 383 | foreach ($this->prefixDirsPsr4[$search] as $dir) { |
384 | - if (file_exists($file = $dir . $pathEnd)) { |
|
384 | + if (file_exists($file = $dir.$pathEnd)) { |
|
385 | 385 | return $file; |
386 | 386 | } |
387 | 387 | } |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | |
392 | 392 | // PSR-4 fallback dirs |
393 | 393 | foreach ($this->fallbackDirsPsr4 as $dir) { |
394 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
394 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr4)) { |
|
395 | 395 | return $file; |
396 | 396 | } |
397 | 397 | } |
@@ -403,14 +403,14 @@ discard block |
||
403 | 403 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
404 | 404 | } else { |
405 | 405 | // PEAR-like class name |
406 | - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
|
406 | + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR).$ext; |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | if (isset($this->prefixesPsr0[$first])) { |
410 | 410 | foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { |
411 | 411 | if (0 === strpos($class, $prefix)) { |
412 | 412 | foreach ($dirs as $dir) { |
413 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
413 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
414 | 414 | return $file; |
415 | 415 | } |
416 | 416 | } |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | |
421 | 421 | // PSR-0 fallback dirs |
422 | 422 | foreach ($this->fallbackDirsPsr0 as $dir) { |
423 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
423 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
424 | 424 | return $file; |
425 | 425 | } |
426 | 426 | } |
@@ -370,18 +370,18 @@ discard block |
||
370 | 370 | private function findFileWithExtension($class, $ext) |
371 | 371 | { |
372 | 372 | // PSR-4 lookup |
373 | - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
|
373 | + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR).$ext; |
|
374 | 374 | |
375 | 375 | $first = $class[0]; |
376 | 376 | if (isset($this->prefixLengthsPsr4[$first])) { |
377 | 377 | $subPath = $class; |
378 | 378 | while (false !== $lastPos = strrpos($subPath, '\\')) { |
379 | 379 | $subPath = substr($subPath, 0, $lastPos); |
380 | - $search = $subPath . '\\'; |
|
380 | + $search = $subPath.'\\'; |
|
381 | 381 | if (isset($this->prefixDirsPsr4[$search])) { |
382 | - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); |
|
382 | + $pathEnd = DIRECTORY_SEPARATOR.substr($logicalPathPsr4, $lastPos + 1); |
|
383 | 383 | foreach ($this->prefixDirsPsr4[$search] as $dir) { |
384 | - if (file_exists($file = $dir . $pathEnd)) { |
|
384 | + if (file_exists($file = $dir.$pathEnd)) { |
|
385 | 385 | return $file; |
386 | 386 | } |
387 | 387 | } |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | |
392 | 392 | // PSR-4 fallback dirs |
393 | 393 | foreach ($this->fallbackDirsPsr4 as $dir) { |
394 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
394 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr4)) { |
|
395 | 395 | return $file; |
396 | 396 | } |
397 | 397 | } |
@@ -403,14 +403,14 @@ discard block |
||
403 | 403 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
404 | 404 | } else { |
405 | 405 | // PEAR-like class name |
406 | - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
|
406 | + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR).$ext; |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | if (isset($this->prefixesPsr0[$first])) { |
410 | 410 | foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { |
411 | 411 | if (0 === strpos($class, $prefix)) { |
412 | 412 | foreach ($dirs as $dir) { |
413 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
413 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
414 | 414 | return $file; |
415 | 415 | } |
416 | 416 | } |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | |
421 | 421 | // PSR-0 fallback dirs |
422 | 422 | foreach ($this->fallbackDirsPsr0 as $dir) { |
423 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
423 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
424 | 424 | return $file; |
425 | 425 | } |
426 | 426 | } |
@@ -370,18 +370,18 @@ discard block |
||
370 | 370 | private function findFileWithExtension($class, $ext) |
371 | 371 | { |
372 | 372 | // PSR-4 lookup |
373 | - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
|
373 | + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR).$ext; |
|
374 | 374 | |
375 | 375 | $first = $class[0]; |
376 | 376 | if (isset($this->prefixLengthsPsr4[$first])) { |
377 | 377 | $subPath = $class; |
378 | 378 | while (false !== $lastPos = strrpos($subPath, '\\')) { |
379 | 379 | $subPath = substr($subPath, 0, $lastPos); |
380 | - $search = $subPath . '\\'; |
|
380 | + $search = $subPath.'\\'; |
|
381 | 381 | if (isset($this->prefixDirsPsr4[$search])) { |
382 | - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); |
|
382 | + $pathEnd = DIRECTORY_SEPARATOR.substr($logicalPathPsr4, $lastPos + 1); |
|
383 | 383 | foreach ($this->prefixDirsPsr4[$search] as $dir) { |
384 | - if (file_exists($file = $dir . $pathEnd)) { |
|
384 | + if (file_exists($file = $dir.$pathEnd)) { |
|
385 | 385 | return $file; |
386 | 386 | } |
387 | 387 | } |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | |
392 | 392 | // PSR-4 fallback dirs |
393 | 393 | foreach ($this->fallbackDirsPsr4 as $dir) { |
394 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
394 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr4)) { |
|
395 | 395 | return $file; |
396 | 396 | } |
397 | 397 | } |
@@ -403,14 +403,14 @@ discard block |
||
403 | 403 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
404 | 404 | } else { |
405 | 405 | // PEAR-like class name |
406 | - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
|
406 | + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR).$ext; |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | if (isset($this->prefixesPsr0[$first])) { |
410 | 410 | foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { |
411 | 411 | if (0 === strpos($class, $prefix)) { |
412 | 412 | foreach ($dirs as $dir) { |
413 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
413 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
414 | 414 | return $file; |
415 | 415 | } |
416 | 416 | } |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | |
421 | 421 | // PSR-0 fallback dirs |
422 | 422 | foreach ($this->fallbackDirsPsr0 as $dir) { |
423 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
423 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
424 | 424 | return $file; |
425 | 425 | } |
426 | 426 | } |
@@ -370,18 +370,18 @@ discard block |
||
370 | 370 | private function findFileWithExtension($class, $ext) |
371 | 371 | { |
372 | 372 | // PSR-4 lookup |
373 | - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
|
373 | + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR).$ext; |
|
374 | 374 | |
375 | 375 | $first = $class[0]; |
376 | 376 | if (isset($this->prefixLengthsPsr4[$first])) { |
377 | 377 | $subPath = $class; |
378 | 378 | while (false !== $lastPos = strrpos($subPath, '\\')) { |
379 | 379 | $subPath = substr($subPath, 0, $lastPos); |
380 | - $search = $subPath . '\\'; |
|
380 | + $search = $subPath.'\\'; |
|
381 | 381 | if (isset($this->prefixDirsPsr4[$search])) { |
382 | - $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); |
|
382 | + $pathEnd = DIRECTORY_SEPARATOR.substr($logicalPathPsr4, $lastPos + 1); |
|
383 | 383 | foreach ($this->prefixDirsPsr4[$search] as $dir) { |
384 | - if (file_exists($file = $dir . $pathEnd)) { |
|
384 | + if (file_exists($file = $dir.$pathEnd)) { |
|
385 | 385 | return $file; |
386 | 386 | } |
387 | 387 | } |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | |
392 | 392 | // PSR-4 fallback dirs |
393 | 393 | foreach ($this->fallbackDirsPsr4 as $dir) { |
394 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
|
394 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr4)) { |
|
395 | 395 | return $file; |
396 | 396 | } |
397 | 397 | } |
@@ -403,14 +403,14 @@ discard block |
||
403 | 403 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
404 | 404 | } else { |
405 | 405 | // PEAR-like class name |
406 | - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
|
406 | + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR).$ext; |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | if (isset($this->prefixesPsr0[$first])) { |
410 | 410 | foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { |
411 | 411 | if (0 === strpos($class, $prefix)) { |
412 | 412 | foreach ($dirs as $dir) { |
413 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
413 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
414 | 414 | return $file; |
415 | 415 | } |
416 | 416 | } |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | |
421 | 421 | // PSR-0 fallback dirs |
422 | 422 | foreach ($this->fallbackDirsPsr0 as $dir) { |
423 | - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
|
423 | + if (file_exists($file = $dir.DIRECTORY_SEPARATOR.$logicalPathPsr0)) { |
|
424 | 424 | return $file; |
425 | 425 | } |
426 | 426 | } |
@@ -25,26 +25,26 @@ |
||
25 | 25 | |
26 | 26 | class EnterpriseBundle extends Bundle { |
27 | 27 | |
28 | - /** |
|
29 | - * {@inheritDoc} |
|
30 | - */ |
|
31 | - public function getName(): string { |
|
32 | - return $this->l10n->t('Enterprise bundle'); |
|
33 | - } |
|
28 | + /** |
|
29 | + * {@inheritDoc} |
|
30 | + */ |
|
31 | + public function getName(): string { |
|
32 | + return $this->l10n->t('Enterprise bundle'); |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * {@inheritDoc} |
|
37 | - */ |
|
38 | - public function getAppIdentifiers(): array { |
|
39 | - return [ |
|
40 | - 'admin_audit', |
|
41 | - 'user_ldap', |
|
42 | - 'files_retention', |
|
43 | - 'files_automatedtagging', |
|
44 | - 'user_saml', |
|
45 | - 'files_accesscontrol', |
|
46 | - 'terms_of_service', |
|
47 | - ]; |
|
48 | - } |
|
35 | + /** |
|
36 | + * {@inheritDoc} |
|
37 | + */ |
|
38 | + public function getAppIdentifiers(): array { |
|
39 | + return [ |
|
40 | + 'admin_audit', |
|
41 | + 'user_ldap', |
|
42 | + 'files_retention', |
|
43 | + 'files_automatedtagging', |
|
44 | + 'user_saml', |
|
45 | + 'files_accesscontrol', |
|
46 | + 'terms_of_service', |
|
47 | + ]; |
|
48 | + } |
|
49 | 49 | |
50 | 50 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $this->groupedShares = $arguments['groupedShares']; |
76 | 76 | |
77 | 77 | $newMountPoint = $this->verifyMountPoint($this->superShare, $mountpoints, $folderExistCache); |
78 | - $absMountPoint = '/' . $this->user . '/files' . $newMountPoint; |
|
78 | + $absMountPoint = '/'.$this->user.'/files'.$newMountPoint; |
|
79 | 79 | parent::__construct($storage, $absMountPoint, $arguments, $loader); |
80 | 80 | } |
81 | 81 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | } |
103 | 103 | |
104 | 104 | $newMountPoint = $this->generateUniqueTarget( |
105 | - \OC\Files\Filesystem::normalizePath($parent . '/' . $mountPoint), |
|
105 | + \OC\Files\Filesystem::normalizePath($parent.'/'.$mountPoint), |
|
106 | 106 | $this->recipientView, |
107 | 107 | $mountpoints |
108 | 108 | ); |
@@ -139,15 +139,15 @@ discard block |
||
139 | 139 | */ |
140 | 140 | private function generateUniqueTarget($path, $view, array $mountpoints) { |
141 | 141 | $pathinfo = pathinfo($path); |
142 | - $ext = isset($pathinfo['extension']) ? '.' . $pathinfo['extension'] : ''; |
|
142 | + $ext = isset($pathinfo['extension']) ? '.'.$pathinfo['extension'] : ''; |
|
143 | 143 | $name = $pathinfo['filename']; |
144 | 144 | $dir = $pathinfo['dirname']; |
145 | 145 | |
146 | 146 | $i = 2; |
147 | - $absolutePath = $this->recipientView->getAbsolutePath($path) . '/'; |
|
147 | + $absolutePath = $this->recipientView->getAbsolutePath($path).'/'; |
|
148 | 148 | while ($view->file_exists($path) || isset($mountpoints[$absolutePath])) { |
149 | - $path = Filesystem::normalizePath($dir . '/' . $name . ' (' . $i . ')' . $ext); |
|
150 | - $absolutePath = $this->recipientView->getAbsolutePath($path) . '/'; |
|
149 | + $path = Filesystem::normalizePath($dir.'/'.$name.' ('.$i.')'.$ext); |
|
150 | + $absolutePath = $this->recipientView->getAbsolutePath($path).'/'; |
|
151 | 151 | $i++; |
152 | 152 | } |
153 | 153 | |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | |
168 | 168 | // it is not a file relative to data/user/files |
169 | 169 | if (count($split) < 3 || $split[1] !== 'files') { |
170 | - \OC::$server->getLogger()->error('Can not strip userid and "files/" from path: ' . $path, ['app' => 'files_sharing']); |
|
170 | + \OC::$server->getLogger()->error('Can not strip userid and "files/" from path: '.$path, ['app' => 'files_sharing']); |
|
171 | 171 | throw new \OCA\Files_Sharing\Exceptions\BrokenPath('Path does not start with /user/files', 10); |
172 | 172 | } |
173 | 173 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | $sliced = array_slice($split, 2); |
176 | 176 | $relPath = implode('/', $sliced); |
177 | 177 | |
178 | - return '/' . $relPath; |
|
178 | + return '/'.$relPath; |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | $this->setMountPoint($target); |
197 | 197 | $this->storage->setMountPoint($relTargetPath); |
198 | 198 | } catch (\Exception $e) { |
199 | - \OC::$server->getLogger()->logException($e, ['app' => 'files_sharing', 'message' => 'Could not rename mount point for shared folder "' . $this->getMountPoint() . '" to "' . $target . '"']); |
|
199 | + \OC::$server->getLogger()->logException($e, ['app' => 'files_sharing', 'message' => 'Could not rename mount point for shared folder "'.$this->getMountPoint().'" to "'.$target.'"']); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | return $result; |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | $row = $result->fetch(); |
251 | 251 | $result->closeCursor(); |
252 | 252 | if ($row) { |
253 | - return (int)$row['storage']; |
|
253 | + return (int) $row['storage']; |
|
254 | 254 | } |
255 | 255 | return -1; |
256 | 256 | } |
@@ -41,228 +41,228 @@ |
||
41 | 41 | * Shared mount points can be moved by the user |
42 | 42 | */ |
43 | 43 | class SharedMount extends MountPoint implements MoveableMount { |
44 | - /** |
|
45 | - * @var \OCA\Files_Sharing\SharedStorage $storage |
|
46 | - */ |
|
47 | - protected $storage = null; |
|
48 | - |
|
49 | - /** |
|
50 | - * @var \OC\Files\View |
|
51 | - */ |
|
52 | - private $recipientView; |
|
53 | - |
|
54 | - /** |
|
55 | - * @var string |
|
56 | - */ |
|
57 | - private $user; |
|
58 | - |
|
59 | - /** @var \OCP\Share\IShare */ |
|
60 | - private $superShare; |
|
61 | - |
|
62 | - /** @var \OCP\Share\IShare[] */ |
|
63 | - private $groupedShares; |
|
64 | - |
|
65 | - /** |
|
66 | - * @param string $storage |
|
67 | - * @param SharedMount[] $mountpoints |
|
68 | - * @param array $arguments |
|
69 | - * @param IStorageFactory $loader |
|
70 | - * @param View $recipientView |
|
71 | - */ |
|
72 | - public function __construct($storage, array $mountpoints, $arguments, IStorageFactory $loader, View $recipientView, CappedMemoryCache $folderExistCache) { |
|
73 | - $this->user = $arguments['user']; |
|
74 | - $this->recipientView = $recipientView; |
|
75 | - |
|
76 | - $this->superShare = $arguments['superShare']; |
|
77 | - $this->groupedShares = $arguments['groupedShares']; |
|
78 | - |
|
79 | - $newMountPoint = $this->verifyMountPoint($this->superShare, $mountpoints, $folderExistCache); |
|
80 | - $absMountPoint = '/' . $this->user . '/files' . $newMountPoint; |
|
81 | - parent::__construct($storage, $absMountPoint, $arguments, $loader); |
|
82 | - } |
|
83 | - |
|
84 | - /** |
|
85 | - * check if the parent folder exists otherwise move the mount point up |
|
86 | - * |
|
87 | - * @param \OCP\Share\IShare $share |
|
88 | - * @param SharedMount[] $mountpoints |
|
89 | - * @return string |
|
90 | - */ |
|
91 | - private function verifyMountPoint(\OCP\Share\IShare $share, array $mountpoints, CappedMemoryCache $folderExistCache) { |
|
92 | - $mountPoint = basename($share->getTarget()); |
|
93 | - $parent = dirname($share->getTarget()); |
|
94 | - |
|
95 | - $event = new VerifyMountPointEvent($share, $this->recipientView, $parent); |
|
96 | - /** @var IEventDispatcher $dispatcher */ |
|
97 | - $dispatcher = \OC::$server->query(IEventDispatcher::class); |
|
98 | - $dispatcher->dispatchTyped($event); |
|
99 | - $parent = $event->getParent(); |
|
100 | - |
|
101 | - if ($folderExistCache->hasKey($parent)) { |
|
102 | - $parentExists = $folderExistCache->get($parent); |
|
103 | - } else { |
|
104 | - $parentExists = $this->recipientView->is_dir($parent); |
|
105 | - $folderExistCache->set($parent, $parentExists); |
|
106 | - } |
|
107 | - if (!$parentExists) { |
|
108 | - $parent = Helper::getShareFolder($this->recipientView, $this->user); |
|
109 | - } |
|
110 | - |
|
111 | - $newMountPoint = $this->generateUniqueTarget( |
|
112 | - \OC\Files\Filesystem::normalizePath($parent . '/' . $mountPoint), |
|
113 | - $this->recipientView, |
|
114 | - $mountpoints |
|
115 | - ); |
|
116 | - |
|
117 | - if ($newMountPoint !== $share->getTarget()) { |
|
118 | - $this->updateFileTarget($newMountPoint, $share); |
|
119 | - } |
|
120 | - |
|
121 | - return $newMountPoint; |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * update fileTarget in the database if the mount point changed |
|
126 | - * |
|
127 | - * @param string $newPath |
|
128 | - * @param \OCP\Share\IShare $share |
|
129 | - * @return bool |
|
130 | - */ |
|
131 | - private function updateFileTarget($newPath, &$share) { |
|
132 | - $share->setTarget($newPath); |
|
133 | - |
|
134 | - foreach ($this->groupedShares as $tmpShare) { |
|
135 | - $tmpShare->setTarget($newPath); |
|
136 | - \OC::$server->getShareManager()->moveShare($tmpShare, $this->user); |
|
137 | - } |
|
138 | - } |
|
139 | - |
|
140 | - |
|
141 | - /** |
|
142 | - * @param string $path |
|
143 | - * @param View $view |
|
144 | - * @param SharedMount[] $mountpoints |
|
145 | - * @return mixed |
|
146 | - */ |
|
147 | - private function generateUniqueTarget($path, $view, array $mountpoints) { |
|
148 | - $pathinfo = pathinfo($path); |
|
149 | - $ext = isset($pathinfo['extension']) ? '.' . $pathinfo['extension'] : ''; |
|
150 | - $name = $pathinfo['filename']; |
|
151 | - $dir = $pathinfo['dirname']; |
|
152 | - |
|
153 | - $i = 2; |
|
154 | - $absolutePath = $this->recipientView->getAbsolutePath($path) . '/'; |
|
155 | - while ($view->file_exists($path) || isset($mountpoints[$absolutePath])) { |
|
156 | - $path = Filesystem::normalizePath($dir . '/' . $name . ' (' . $i . ')' . $ext); |
|
157 | - $absolutePath = $this->recipientView->getAbsolutePath($path) . '/'; |
|
158 | - $i++; |
|
159 | - } |
|
160 | - |
|
161 | - return $path; |
|
162 | - } |
|
163 | - |
|
164 | - /** |
|
165 | - * Format a path to be relative to the /user/files/ directory |
|
166 | - * |
|
167 | - * @param string $path the absolute path |
|
168 | - * @return string e.g. turns '/admin/files/test.txt' into '/test.txt' |
|
169 | - * @throws \OCA\Files_Sharing\Exceptions\BrokenPath |
|
170 | - */ |
|
171 | - protected function stripUserFilesPath($path) { |
|
172 | - $trimmed = ltrim($path, '/'); |
|
173 | - $split = explode('/', $trimmed); |
|
174 | - |
|
175 | - // it is not a file relative to data/user/files |
|
176 | - if (count($split) < 3 || $split[1] !== 'files') { |
|
177 | - \OC::$server->getLogger()->error('Can not strip userid and "files/" from path: ' . $path, ['app' => 'files_sharing']); |
|
178 | - throw new \OCA\Files_Sharing\Exceptions\BrokenPath('Path does not start with /user/files', 10); |
|
179 | - } |
|
180 | - |
|
181 | - // skip 'user' and 'files' |
|
182 | - $sliced = array_slice($split, 2); |
|
183 | - $relPath = implode('/', $sliced); |
|
184 | - |
|
185 | - return '/' . $relPath; |
|
186 | - } |
|
187 | - |
|
188 | - /** |
|
189 | - * Move the mount point to $target |
|
190 | - * |
|
191 | - * @param string $target the target mount point |
|
192 | - * @return bool |
|
193 | - */ |
|
194 | - public function moveMount($target) { |
|
195 | - $relTargetPath = $this->stripUserFilesPath($target); |
|
196 | - $share = $this->storage->getShare(); |
|
197 | - |
|
198 | - $result = true; |
|
199 | - |
|
200 | - try { |
|
201 | - $this->updateFileTarget($relTargetPath, $share); |
|
202 | - $this->setMountPoint($target); |
|
203 | - $this->storage->setMountPoint($relTargetPath); |
|
204 | - } catch (\Exception $e) { |
|
205 | - \OC::$server->getLogger()->logException($e, ['app' => 'files_sharing', 'message' => 'Could not rename mount point for shared folder "' . $this->getMountPoint() . '" to "' . $target . '"']); |
|
206 | - } |
|
207 | - |
|
208 | - return $result; |
|
209 | - } |
|
210 | - |
|
211 | - /** |
|
212 | - * Remove the mount points |
|
213 | - * |
|
214 | - * @return bool |
|
215 | - */ |
|
216 | - public function removeMount() { |
|
217 | - $mountManager = \OC\Files\Filesystem::getMountManager(); |
|
218 | - /** @var \OCA\Files_Sharing\SharedStorage $storage */ |
|
219 | - $storage = $this->getStorage(); |
|
220 | - $result = $storage->unshareStorage(); |
|
221 | - $mountManager->removeMount($this->mountPoint); |
|
222 | - |
|
223 | - return $result; |
|
224 | - } |
|
225 | - |
|
226 | - /** |
|
227 | - * @return \OCP\Share\IShare |
|
228 | - */ |
|
229 | - public function getShare() { |
|
230 | - return $this->superShare; |
|
231 | - } |
|
232 | - |
|
233 | - /** |
|
234 | - * Get the file id of the root of the storage |
|
235 | - * |
|
236 | - * @return int |
|
237 | - */ |
|
238 | - public function getStorageRootId() { |
|
239 | - return $this->getShare()->getNodeId(); |
|
240 | - } |
|
241 | - |
|
242 | - /** |
|
243 | - * @return int |
|
244 | - */ |
|
245 | - public function getNumericStorageId() { |
|
246 | - if (!is_null($this->getShare()->getNodeCacheEntry())) { |
|
247 | - return $this->getShare()->getNodeCacheEntry()->getStorageId(); |
|
248 | - } else { |
|
249 | - $builder = \OC::$server->getDatabaseConnection()->getQueryBuilder(); |
|
250 | - |
|
251 | - $query = $builder->select('storage') |
|
252 | - ->from('filecache') |
|
253 | - ->where($builder->expr()->eq('fileid', $builder->createNamedParameter($this->getStorageRootId()))); |
|
254 | - |
|
255 | - $result = $query->execute(); |
|
256 | - $row = $result->fetch(); |
|
257 | - $result->closeCursor(); |
|
258 | - if ($row) { |
|
259 | - return (int)$row['storage']; |
|
260 | - } |
|
261 | - return -1; |
|
262 | - } |
|
263 | - } |
|
264 | - |
|
265 | - public function getMountType() { |
|
266 | - return 'shared'; |
|
267 | - } |
|
44 | + /** |
|
45 | + * @var \OCA\Files_Sharing\SharedStorage $storage |
|
46 | + */ |
|
47 | + protected $storage = null; |
|
48 | + |
|
49 | + /** |
|
50 | + * @var \OC\Files\View |
|
51 | + */ |
|
52 | + private $recipientView; |
|
53 | + |
|
54 | + /** |
|
55 | + * @var string |
|
56 | + */ |
|
57 | + private $user; |
|
58 | + |
|
59 | + /** @var \OCP\Share\IShare */ |
|
60 | + private $superShare; |
|
61 | + |
|
62 | + /** @var \OCP\Share\IShare[] */ |
|
63 | + private $groupedShares; |
|
64 | + |
|
65 | + /** |
|
66 | + * @param string $storage |
|
67 | + * @param SharedMount[] $mountpoints |
|
68 | + * @param array $arguments |
|
69 | + * @param IStorageFactory $loader |
|
70 | + * @param View $recipientView |
|
71 | + */ |
|
72 | + public function __construct($storage, array $mountpoints, $arguments, IStorageFactory $loader, View $recipientView, CappedMemoryCache $folderExistCache) { |
|
73 | + $this->user = $arguments['user']; |
|
74 | + $this->recipientView = $recipientView; |
|
75 | + |
|
76 | + $this->superShare = $arguments['superShare']; |
|
77 | + $this->groupedShares = $arguments['groupedShares']; |
|
78 | + |
|
79 | + $newMountPoint = $this->verifyMountPoint($this->superShare, $mountpoints, $folderExistCache); |
|
80 | + $absMountPoint = '/' . $this->user . '/files' . $newMountPoint; |
|
81 | + parent::__construct($storage, $absMountPoint, $arguments, $loader); |
|
82 | + } |
|
83 | + |
|
84 | + /** |
|
85 | + * check if the parent folder exists otherwise move the mount point up |
|
86 | + * |
|
87 | + * @param \OCP\Share\IShare $share |
|
88 | + * @param SharedMount[] $mountpoints |
|
89 | + * @return string |
|
90 | + */ |
|
91 | + private function verifyMountPoint(\OCP\Share\IShare $share, array $mountpoints, CappedMemoryCache $folderExistCache) { |
|
92 | + $mountPoint = basename($share->getTarget()); |
|
93 | + $parent = dirname($share->getTarget()); |
|
94 | + |
|
95 | + $event = new VerifyMountPointEvent($share, $this->recipientView, $parent); |
|
96 | + /** @var IEventDispatcher $dispatcher */ |
|
97 | + $dispatcher = \OC::$server->query(IEventDispatcher::class); |
|
98 | + $dispatcher->dispatchTyped($event); |
|
99 | + $parent = $event->getParent(); |
|
100 | + |
|
101 | + if ($folderExistCache->hasKey($parent)) { |
|
102 | + $parentExists = $folderExistCache->get($parent); |
|
103 | + } else { |
|
104 | + $parentExists = $this->recipientView->is_dir($parent); |
|
105 | + $folderExistCache->set($parent, $parentExists); |
|
106 | + } |
|
107 | + if (!$parentExists) { |
|
108 | + $parent = Helper::getShareFolder($this->recipientView, $this->user); |
|
109 | + } |
|
110 | + |
|
111 | + $newMountPoint = $this->generateUniqueTarget( |
|
112 | + \OC\Files\Filesystem::normalizePath($parent . '/' . $mountPoint), |
|
113 | + $this->recipientView, |
|
114 | + $mountpoints |
|
115 | + ); |
|
116 | + |
|
117 | + if ($newMountPoint !== $share->getTarget()) { |
|
118 | + $this->updateFileTarget($newMountPoint, $share); |
|
119 | + } |
|
120 | + |
|
121 | + return $newMountPoint; |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * update fileTarget in the database if the mount point changed |
|
126 | + * |
|
127 | + * @param string $newPath |
|
128 | + * @param \OCP\Share\IShare $share |
|
129 | + * @return bool |
|
130 | + */ |
|
131 | + private function updateFileTarget($newPath, &$share) { |
|
132 | + $share->setTarget($newPath); |
|
133 | + |
|
134 | + foreach ($this->groupedShares as $tmpShare) { |
|
135 | + $tmpShare->setTarget($newPath); |
|
136 | + \OC::$server->getShareManager()->moveShare($tmpShare, $this->user); |
|
137 | + } |
|
138 | + } |
|
139 | + |
|
140 | + |
|
141 | + /** |
|
142 | + * @param string $path |
|
143 | + * @param View $view |
|
144 | + * @param SharedMount[] $mountpoints |
|
145 | + * @return mixed |
|
146 | + */ |
|
147 | + private function generateUniqueTarget($path, $view, array $mountpoints) { |
|
148 | + $pathinfo = pathinfo($path); |
|
149 | + $ext = isset($pathinfo['extension']) ? '.' . $pathinfo['extension'] : ''; |
|
150 | + $name = $pathinfo['filename']; |
|
151 | + $dir = $pathinfo['dirname']; |
|
152 | + |
|
153 | + $i = 2; |
|
154 | + $absolutePath = $this->recipientView->getAbsolutePath($path) . '/'; |
|
155 | + while ($view->file_exists($path) || isset($mountpoints[$absolutePath])) { |
|
156 | + $path = Filesystem::normalizePath($dir . '/' . $name . ' (' . $i . ')' . $ext); |
|
157 | + $absolutePath = $this->recipientView->getAbsolutePath($path) . '/'; |
|
158 | + $i++; |
|
159 | + } |
|
160 | + |
|
161 | + return $path; |
|
162 | + } |
|
163 | + |
|
164 | + /** |
|
165 | + * Format a path to be relative to the /user/files/ directory |
|
166 | + * |
|
167 | + * @param string $path the absolute path |
|
168 | + * @return string e.g. turns '/admin/files/test.txt' into '/test.txt' |
|
169 | + * @throws \OCA\Files_Sharing\Exceptions\BrokenPath |
|
170 | + */ |
|
171 | + protected function stripUserFilesPath($path) { |
|
172 | + $trimmed = ltrim($path, '/'); |
|
173 | + $split = explode('/', $trimmed); |
|
174 | + |
|
175 | + // it is not a file relative to data/user/files |
|
176 | + if (count($split) < 3 || $split[1] !== 'files') { |
|
177 | + \OC::$server->getLogger()->error('Can not strip userid and "files/" from path: ' . $path, ['app' => 'files_sharing']); |
|
178 | + throw new \OCA\Files_Sharing\Exceptions\BrokenPath('Path does not start with /user/files', 10); |
|
179 | + } |
|
180 | + |
|
181 | + // skip 'user' and 'files' |
|
182 | + $sliced = array_slice($split, 2); |
|
183 | + $relPath = implode('/', $sliced); |
|
184 | + |
|
185 | + return '/' . $relPath; |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | + * Move the mount point to $target |
|
190 | + * |
|
191 | + * @param string $target the target mount point |
|
192 | + * @return bool |
|
193 | + */ |
|
194 | + public function moveMount($target) { |
|
195 | + $relTargetPath = $this->stripUserFilesPath($target); |
|
196 | + $share = $this->storage->getShare(); |
|
197 | + |
|
198 | + $result = true; |
|
199 | + |
|
200 | + try { |
|
201 | + $this->updateFileTarget($relTargetPath, $share); |
|
202 | + $this->setMountPoint($target); |
|
203 | + $this->storage->setMountPoint($relTargetPath); |
|
204 | + } catch (\Exception $e) { |
|
205 | + \OC::$server->getLogger()->logException($e, ['app' => 'files_sharing', 'message' => 'Could not rename mount point for shared folder "' . $this->getMountPoint() . '" to "' . $target . '"']); |
|
206 | + } |
|
207 | + |
|
208 | + return $result; |
|
209 | + } |
|
210 | + |
|
211 | + /** |
|
212 | + * Remove the mount points |
|
213 | + * |
|
214 | + * @return bool |
|
215 | + */ |
|
216 | + public function removeMount() { |
|
217 | + $mountManager = \OC\Files\Filesystem::getMountManager(); |
|
218 | + /** @var \OCA\Files_Sharing\SharedStorage $storage */ |
|
219 | + $storage = $this->getStorage(); |
|
220 | + $result = $storage->unshareStorage(); |
|
221 | + $mountManager->removeMount($this->mountPoint); |
|
222 | + |
|
223 | + return $result; |
|
224 | + } |
|
225 | + |
|
226 | + /** |
|
227 | + * @return \OCP\Share\IShare |
|
228 | + */ |
|
229 | + public function getShare() { |
|
230 | + return $this->superShare; |
|
231 | + } |
|
232 | + |
|
233 | + /** |
|
234 | + * Get the file id of the root of the storage |
|
235 | + * |
|
236 | + * @return int |
|
237 | + */ |
|
238 | + public function getStorageRootId() { |
|
239 | + return $this->getShare()->getNodeId(); |
|
240 | + } |
|
241 | + |
|
242 | + /** |
|
243 | + * @return int |
|
244 | + */ |
|
245 | + public function getNumericStorageId() { |
|
246 | + if (!is_null($this->getShare()->getNodeCacheEntry())) { |
|
247 | + return $this->getShare()->getNodeCacheEntry()->getStorageId(); |
|
248 | + } else { |
|
249 | + $builder = \OC::$server->getDatabaseConnection()->getQueryBuilder(); |
|
250 | + |
|
251 | + $query = $builder->select('storage') |
|
252 | + ->from('filecache') |
|
253 | + ->where($builder->expr()->eq('fileid', $builder->createNamedParameter($this->getStorageRootId()))); |
|
254 | + |
|
255 | + $result = $query->execute(); |
|
256 | + $row = $result->fetch(); |
|
257 | + $result->closeCursor(); |
|
258 | + if ($row) { |
|
259 | + return (int)$row['storage']; |
|
260 | + } |
|
261 | + return -1; |
|
262 | + } |
|
263 | + } |
|
264 | + |
|
265 | + public function getMountType() { |
|
266 | + return 'shared'; |
|
267 | + } |
|
268 | 268 | } |
@@ -32,166 +32,166 @@ |
||
32 | 32 | use OCP\Files\Mount\IMountPoint; |
33 | 33 | |
34 | 34 | class Manager implements IMountManager { |
35 | - /** @var MountPoint[] */ |
|
36 | - private $mounts = []; |
|
37 | - |
|
38 | - /** @var CappedMemoryCache */ |
|
39 | - private $pathCache; |
|
40 | - |
|
41 | - /** @var CappedMemoryCache */ |
|
42 | - private $inPathCache; |
|
43 | - |
|
44 | - public function __construct() { |
|
45 | - $this->pathCache = new CappedMemoryCache(); |
|
46 | - $this->inPathCache = new CappedMemoryCache(); |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * @param IMountPoint $mount |
|
51 | - */ |
|
52 | - public function addMount(IMountPoint $mount) { |
|
53 | - $this->mounts[$mount->getMountPoint()] = $mount; |
|
54 | - $this->pathCache->clear(); |
|
55 | - $this->inPathCache->clear(); |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * @param string $mountPoint |
|
60 | - */ |
|
61 | - public function removeMount(string $mountPoint) { |
|
62 | - $mountPoint = Filesystem::normalizePath($mountPoint); |
|
63 | - if (\strlen($mountPoint) > 1) { |
|
64 | - $mountPoint .= '/'; |
|
65 | - } |
|
66 | - unset($this->mounts[$mountPoint]); |
|
67 | - $this->pathCache->clear(); |
|
68 | - $this->inPathCache->clear(); |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * @param string $mountPoint |
|
73 | - * @param string $target |
|
74 | - */ |
|
75 | - public function moveMount(string $mountPoint, string $target) { |
|
76 | - $this->mounts[$target] = $this->mounts[$mountPoint]; |
|
77 | - unset($this->mounts[$mountPoint]); |
|
78 | - $this->pathCache->clear(); |
|
79 | - $this->inPathCache->clear(); |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * Find the mount for $path |
|
84 | - * |
|
85 | - * @param string $path |
|
86 | - * @return MountPoint|null |
|
87 | - */ |
|
88 | - public function find(string $path) { |
|
89 | - \OC_Util::setupFS(); |
|
90 | - $path = Filesystem::normalizePath($path); |
|
91 | - |
|
92 | - if (isset($this->pathCache[$path])) { |
|
93 | - return $this->pathCache[$path]; |
|
94 | - } |
|
95 | - |
|
96 | - $current = $path; |
|
97 | - while (true) { |
|
98 | - $mountPoint = $current . '/'; |
|
99 | - if (isset($this->mounts[$mountPoint])) { |
|
100 | - $this->pathCache[$path] = $this->mounts[$mountPoint]; |
|
101 | - return $this->mounts[$mountPoint]; |
|
102 | - } |
|
103 | - |
|
104 | - if ($current === '') { |
|
105 | - return null; |
|
106 | - } |
|
107 | - |
|
108 | - $current = dirname($current); |
|
109 | - if ($current === '.' || $current === '/') { |
|
110 | - $current = ''; |
|
111 | - } |
|
112 | - } |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * Find all mounts in $path |
|
117 | - * |
|
118 | - * @param string $path |
|
119 | - * @return MountPoint[] |
|
120 | - */ |
|
121 | - public function findIn(string $path): array { |
|
122 | - \OC_Util::setupFS(); |
|
123 | - $path = $this->formatPath($path); |
|
124 | - |
|
125 | - if (isset($this->inPathCache[$path])) { |
|
126 | - return $this->inPathCache[$path]; |
|
127 | - } |
|
128 | - |
|
129 | - $result = []; |
|
130 | - $pathLength = \strlen($path); |
|
131 | - $mountPoints = array_keys($this->mounts); |
|
132 | - foreach ($mountPoints as $mountPoint) { |
|
133 | - if (substr($mountPoint, 0, $pathLength) === $path && \strlen($mountPoint) > $pathLength) { |
|
134 | - $result[] = $this->mounts[$mountPoint]; |
|
135 | - } |
|
136 | - } |
|
137 | - |
|
138 | - $this->inPathCache[$path] = $result; |
|
139 | - return $result; |
|
140 | - } |
|
141 | - |
|
142 | - public function clear() { |
|
143 | - $this->mounts = []; |
|
144 | - $this->pathCache->clear(); |
|
145 | - $this->inPathCache->clear(); |
|
146 | - } |
|
147 | - |
|
148 | - /** |
|
149 | - * Find mounts by storage id |
|
150 | - * |
|
151 | - * @param string $id |
|
152 | - * @return MountPoint[] |
|
153 | - */ |
|
154 | - public function findByStorageId(string $id): array { |
|
155 | - \OC_Util::setupFS(); |
|
156 | - if (\strlen($id) > 64) { |
|
157 | - $id = md5($id); |
|
158 | - } |
|
159 | - $result = []; |
|
160 | - foreach ($this->mounts as $mount) { |
|
161 | - if ($mount->getStorageId() === $id) { |
|
162 | - $result[] = $mount; |
|
163 | - } |
|
164 | - } |
|
165 | - return $result; |
|
166 | - } |
|
167 | - |
|
168 | - /** |
|
169 | - * @return MountPoint[] |
|
170 | - */ |
|
171 | - public function getAll(): array { |
|
172 | - return $this->mounts; |
|
173 | - } |
|
174 | - |
|
175 | - /** |
|
176 | - * Find mounts by numeric storage id |
|
177 | - * |
|
178 | - * @param int $id |
|
179 | - * @return MountPoint[] |
|
180 | - */ |
|
181 | - public function findByNumericId(int $id): array { |
|
182 | - $storageId = \OC\Files\Cache\Storage::getStorageId($id); |
|
183 | - return $this->findByStorageId($storageId); |
|
184 | - } |
|
185 | - |
|
186 | - /** |
|
187 | - * @param string $path |
|
188 | - * @return string |
|
189 | - */ |
|
190 | - private function formatPath(string $path): string { |
|
191 | - $path = Filesystem::normalizePath($path); |
|
192 | - if (\strlen($path) > 1) { |
|
193 | - $path .= '/'; |
|
194 | - } |
|
195 | - return $path; |
|
196 | - } |
|
35 | + /** @var MountPoint[] */ |
|
36 | + private $mounts = []; |
|
37 | + |
|
38 | + /** @var CappedMemoryCache */ |
|
39 | + private $pathCache; |
|
40 | + |
|
41 | + /** @var CappedMemoryCache */ |
|
42 | + private $inPathCache; |
|
43 | + |
|
44 | + public function __construct() { |
|
45 | + $this->pathCache = new CappedMemoryCache(); |
|
46 | + $this->inPathCache = new CappedMemoryCache(); |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * @param IMountPoint $mount |
|
51 | + */ |
|
52 | + public function addMount(IMountPoint $mount) { |
|
53 | + $this->mounts[$mount->getMountPoint()] = $mount; |
|
54 | + $this->pathCache->clear(); |
|
55 | + $this->inPathCache->clear(); |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * @param string $mountPoint |
|
60 | + */ |
|
61 | + public function removeMount(string $mountPoint) { |
|
62 | + $mountPoint = Filesystem::normalizePath($mountPoint); |
|
63 | + if (\strlen($mountPoint) > 1) { |
|
64 | + $mountPoint .= '/'; |
|
65 | + } |
|
66 | + unset($this->mounts[$mountPoint]); |
|
67 | + $this->pathCache->clear(); |
|
68 | + $this->inPathCache->clear(); |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * @param string $mountPoint |
|
73 | + * @param string $target |
|
74 | + */ |
|
75 | + public function moveMount(string $mountPoint, string $target) { |
|
76 | + $this->mounts[$target] = $this->mounts[$mountPoint]; |
|
77 | + unset($this->mounts[$mountPoint]); |
|
78 | + $this->pathCache->clear(); |
|
79 | + $this->inPathCache->clear(); |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * Find the mount for $path |
|
84 | + * |
|
85 | + * @param string $path |
|
86 | + * @return MountPoint|null |
|
87 | + */ |
|
88 | + public function find(string $path) { |
|
89 | + \OC_Util::setupFS(); |
|
90 | + $path = Filesystem::normalizePath($path); |
|
91 | + |
|
92 | + if (isset($this->pathCache[$path])) { |
|
93 | + return $this->pathCache[$path]; |
|
94 | + } |
|
95 | + |
|
96 | + $current = $path; |
|
97 | + while (true) { |
|
98 | + $mountPoint = $current . '/'; |
|
99 | + if (isset($this->mounts[$mountPoint])) { |
|
100 | + $this->pathCache[$path] = $this->mounts[$mountPoint]; |
|
101 | + return $this->mounts[$mountPoint]; |
|
102 | + } |
|
103 | + |
|
104 | + if ($current === '') { |
|
105 | + return null; |
|
106 | + } |
|
107 | + |
|
108 | + $current = dirname($current); |
|
109 | + if ($current === '.' || $current === '/') { |
|
110 | + $current = ''; |
|
111 | + } |
|
112 | + } |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * Find all mounts in $path |
|
117 | + * |
|
118 | + * @param string $path |
|
119 | + * @return MountPoint[] |
|
120 | + */ |
|
121 | + public function findIn(string $path): array { |
|
122 | + \OC_Util::setupFS(); |
|
123 | + $path = $this->formatPath($path); |
|
124 | + |
|
125 | + if (isset($this->inPathCache[$path])) { |
|
126 | + return $this->inPathCache[$path]; |
|
127 | + } |
|
128 | + |
|
129 | + $result = []; |
|
130 | + $pathLength = \strlen($path); |
|
131 | + $mountPoints = array_keys($this->mounts); |
|
132 | + foreach ($mountPoints as $mountPoint) { |
|
133 | + if (substr($mountPoint, 0, $pathLength) === $path && \strlen($mountPoint) > $pathLength) { |
|
134 | + $result[] = $this->mounts[$mountPoint]; |
|
135 | + } |
|
136 | + } |
|
137 | + |
|
138 | + $this->inPathCache[$path] = $result; |
|
139 | + return $result; |
|
140 | + } |
|
141 | + |
|
142 | + public function clear() { |
|
143 | + $this->mounts = []; |
|
144 | + $this->pathCache->clear(); |
|
145 | + $this->inPathCache->clear(); |
|
146 | + } |
|
147 | + |
|
148 | + /** |
|
149 | + * Find mounts by storage id |
|
150 | + * |
|
151 | + * @param string $id |
|
152 | + * @return MountPoint[] |
|
153 | + */ |
|
154 | + public function findByStorageId(string $id): array { |
|
155 | + \OC_Util::setupFS(); |
|
156 | + if (\strlen($id) > 64) { |
|
157 | + $id = md5($id); |
|
158 | + } |
|
159 | + $result = []; |
|
160 | + foreach ($this->mounts as $mount) { |
|
161 | + if ($mount->getStorageId() === $id) { |
|
162 | + $result[] = $mount; |
|
163 | + } |
|
164 | + } |
|
165 | + return $result; |
|
166 | + } |
|
167 | + |
|
168 | + /** |
|
169 | + * @return MountPoint[] |
|
170 | + */ |
|
171 | + public function getAll(): array { |
|
172 | + return $this->mounts; |
|
173 | + } |
|
174 | + |
|
175 | + /** |
|
176 | + * Find mounts by numeric storage id |
|
177 | + * |
|
178 | + * @param int $id |
|
179 | + * @return MountPoint[] |
|
180 | + */ |
|
181 | + public function findByNumericId(int $id): array { |
|
182 | + $storageId = \OC\Files\Cache\Storage::getStorageId($id); |
|
183 | + return $this->findByStorageId($storageId); |
|
184 | + } |
|
185 | + |
|
186 | + /** |
|
187 | + * @param string $path |
|
188 | + * @return string |
|
189 | + */ |
|
190 | + private function formatPath(string $path): string { |
|
191 | + $path = Filesystem::normalizePath($path); |
|
192 | + if (\strlen($path) > 1) { |
|
193 | + $path .= '/'; |
|
194 | + } |
|
195 | + return $path; |
|
196 | + } |
|
197 | 197 | } |
@@ -95,7 +95,7 @@ |
||
95 | 95 | |
96 | 96 | $current = $path; |
97 | 97 | while (true) { |
98 | - $mountPoint = $current . '/'; |
|
98 | + $mountPoint = $current.'/'; |
|
99 | 99 | if (isset($this->mounts[$mountPoint])) { |
100 | 100 | $this->pathCache[$path] = $this->mounts[$mountPoint]; |
101 | 101 | return $this->mounts[$mountPoint]; |
@@ -29,15 +29,15 @@ |
||
29 | 29 | */ |
30 | 30 | interface ICollectBreadcrumbs extends IReporter { |
31 | 31 | |
32 | - /** |
|
33 | - * Collect breadcrumbs for crash reports |
|
34 | - * |
|
35 | - * @param string $message |
|
36 | - * @param string $category |
|
37 | - * @param array $context |
|
38 | - * |
|
39 | - * @since 15.0.0 |
|
40 | - */ |
|
41 | - public function collect(string $message, string $category, array $context = []); |
|
32 | + /** |
|
33 | + * Collect breadcrumbs for crash reports |
|
34 | + * |
|
35 | + * @param string $message |
|
36 | + * @param string $category |
|
37 | + * @param array $context |
|
38 | + * |
|
39 | + * @since 15.0.0 |
|
40 | + */ |
|
41 | + public function collect(string $message, string $category, array $context = []); |
|
42 | 42 | |
43 | 43 | } |