@@ -86,10 +86,10 @@ discard block |
||
| 86 | 86 | $this->share = $this->server->getShare(trim($params['share'], '/')); |
| 87 | 87 | |
| 88 | 88 | $this->root = $params['root'] ?? '/'; |
| 89 | - $this->root = '/' . ltrim($this->root, '/'); |
|
| 90 | - $this->root = rtrim($this->root, '/') . '/'; |
|
| 89 | + $this->root = '/'.ltrim($this->root, '/'); |
|
| 90 | + $this->root = rtrim($this->root, '/').'/'; |
|
| 91 | 91 | } else { |
| 92 | - throw new \Exception('Invalid configuration: ' . json_encode($params)); |
|
| 92 | + throw new \Exception('Invalid configuration: '.json_encode($params)); |
|
| 93 | 93 | } |
| 94 | 94 | $this->statCache = new CappedMemoryCache(); |
| 95 | 95 | parent::__construct($params); |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | // FIXME: double slash to keep compatible with the old storage ids, |
| 113 | 113 | // failure to do so will lead to creation of a new storage id and |
| 114 | 114 | // loss of shares from the storage |
| 115 | - return 'smb::' . $this->server->getAuth()->getUsername() . '@' . $this->server->getHost() . '//' . $this->share->getName() . '/' . $this->root; |
|
| 115 | + return 'smb::'.$this->server->getAuth()->getUsername().'@'.$this->server->getHost().'//'.$this->share->getName().'/'.$this->root; |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | * @return string |
| 121 | 121 | */ |
| 122 | 122 | protected function buildPath($path) { |
| 123 | - return Filesystem::normalizePath($this->root . '/' . $path, true, false, true); |
|
| 123 | + return Filesystem::normalizePath($this->root.'/'.$path, true, false, true); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | protected function relativePath($fullPath) { |
@@ -160,9 +160,9 @@ discard block |
||
| 160 | 160 | $path = $this->buildPath($path); |
| 161 | 161 | $files = $this->share->dir($path); |
| 162 | 162 | foreach ($files as $file) { |
| 163 | - $this->statCache[$path . '/' . $file->getName()] = $file; |
|
| 163 | + $this->statCache[$path.'/'.$file->getName()] = $file; |
|
| 164 | 164 | } |
| 165 | - return array_filter($files, function (IFileInfo $file) { |
|
| 165 | + return array_filter($files, function(IFileInfo $file) { |
|
| 166 | 166 | try { |
| 167 | 167 | return !$file->isHidden(); |
| 168 | 168 | } catch (ForbiddenException $e) { |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | case 'w': |
| 337 | 337 | case 'wb': |
| 338 | 338 | $source = $this->share->write($fullPath); |
| 339 | - return CallBackWrapper::wrap($source, null, null, function () use ($fullPath) { |
|
| 339 | + return CallBackWrapper::wrap($source, null, null, function() use ($fullPath) { |
|
| 340 | 340 | unset($this->statCache[$fullPath]); |
| 341 | 341 | }); |
| 342 | 342 | case 'a': |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | } |
| 369 | 369 | $source = fopen($tmpFile, $mode); |
| 370 | 370 | $share = $this->share; |
| 371 | - return CallbackWrapper::wrap($source, null, null, function () use ($tmpFile, $fullPath, $share) { |
|
| 371 | + return CallbackWrapper::wrap($source, null, null, function() use ($tmpFile, $fullPath, $share) { |
|
| 372 | 372 | unset($this->statCache[$fullPath]); |
| 373 | 373 | $share->put($tmpFile, $fullPath); |
| 374 | 374 | unlink($tmpFile); |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | $content = $this->share->dir($this->buildPath($path)); |
| 395 | 395 | foreach ($content as $file) { |
| 396 | 396 | if ($file->isDirectory()) { |
| 397 | - $this->rmdir($path . '/' . $file->getName()); |
|
| 397 | + $this->rmdir($path.'/'.$file->getName()); |
|
| 398 | 398 | } else { |
| 399 | 399 | $this->share->del($file->getPath()); |
| 400 | 400 | } |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | } catch (ForbiddenException $e) { |
| 432 | 432 | return false; |
| 433 | 433 | } |
| 434 | - $names = array_map(function ($info) { |
|
| 434 | + $names = array_map(function($info) { |
|
| 435 | 435 | /** @var \Icewind\SMB\IFileInfo $info */ |
| 436 | 436 | return $info->getName(); |
| 437 | 437 | }, $files); |
@@ -513,7 +513,7 @@ discard block |
||
| 513 | 513 | */ |
| 514 | 514 | public static function checkDependencies() { |
| 515 | 515 | return ( |
| 516 | - (bool)\OC_Helper::findBinaryPath('smbclient') |
|
| 516 | + (bool) \OC_Helper::findBinaryPath('smbclient') |
|
| 517 | 517 | || NativeServer::available(new System()) |
| 518 | 518 | ) ? true : ['smbclient']; |
| 519 | 519 | } |
@@ -532,7 +532,7 @@ discard block |
||
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | public function listen($path, callable $callback) { |
| 535 | - $this->notify($path)->listen(function (IChange $change) use ($callback) { |
|
| 535 | + $this->notify($path)->listen(function(IChange $change) use ($callback) { |
|
| 536 | 536 | if ($change instanceof IRenameChange) { |
| 537 | 537 | return $callback($change->getType(), $change->getPath(), $change->getTargetPath()); |
| 538 | 538 | } else { |
@@ -542,7 +542,7 @@ discard block |
||
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | public function notify($path) { |
| 545 | - $path = '/' . ltrim($path, '/'); |
|
| 545 | + $path = '/'.ltrim($path, '/'); |
|
| 546 | 546 | $shareNotifyHandler = $this->share->notify($this->buildPath($path)); |
| 547 | 547 | return new SMBNotifyHandler($shareNotifyHandler, $this->root); |
| 548 | 548 | } |
@@ -73,17 +73,17 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | protected function getStorageConfigFromDBMount(array $mount) { |
| 76 | - $applicableUsers = array_filter($mount['applicable'], function ($applicable) { |
|
| 76 | + $applicableUsers = array_filter($mount['applicable'], function($applicable) { |
|
| 77 | 77 | return $applicable['type'] === DBConfigService::APPLICABLE_TYPE_USER; |
| 78 | 78 | }); |
| 79 | - $applicableUsers = array_map(function ($applicable) { |
|
| 79 | + $applicableUsers = array_map(function($applicable) { |
|
| 80 | 80 | return $applicable['value']; |
| 81 | 81 | }, $applicableUsers); |
| 82 | 82 | |
| 83 | - $applicableGroups = array_filter($mount['applicable'], function ($applicable) { |
|
| 83 | + $applicableGroups = array_filter($mount['applicable'], function($applicable) { |
|
| 84 | 84 | return $applicable['type'] === DBConfigService::APPLICABLE_TYPE_GROUP; |
| 85 | 85 | }); |
| 86 | - $applicableGroups = array_map(function ($applicable) { |
|
| 86 | + $applicableGroups = array_map(function($applicable) { |
|
| 87 | 87 | return $applicable['value']; |
| 88 | 88 | }, $applicableGroups); |
| 89 | 89 | |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | $mount['priority'] |
| 100 | 100 | ); |
| 101 | 101 | $config->setType($mount['type']); |
| 102 | - $config->setId((int)$mount['mount_id']); |
|
| 102 | + $config->setId((int) $mount['mount_id']); |
|
| 103 | 103 | return $config; |
| 104 | 104 | } catch (\UnexpectedValueException $e) { |
| 105 | 105 | // don't die if a storage backend doesn't exist |
@@ -127,11 +127,11 @@ discard block |
||
| 127 | 127 | protected function readConfig() { |
| 128 | 128 | $mounts = $this->readDBConfig(); |
| 129 | 129 | $configs = array_map([$this, 'getStorageConfigFromDBMount'], $mounts); |
| 130 | - $configs = array_filter($configs, function ($config) { |
|
| 130 | + $configs = array_filter($configs, function($config) { |
|
| 131 | 131 | return $config instanceof StorageConfig; |
| 132 | 132 | }); |
| 133 | 133 | |
| 134 | - $keys = array_map(function (StorageConfig $config) { |
|
| 134 | + $keys = array_map(function(StorageConfig $config) { |
|
| 135 | 135 | return $config->getId(); |
| 136 | 136 | }, $configs); |
| 137 | 137 | |
@@ -150,14 +150,14 @@ discard block |
||
| 150 | 150 | $mount = $this->dbConfig->getMountById($id); |
| 151 | 151 | |
| 152 | 152 | if (!is_array($mount)) { |
| 153 | - throw new NotFoundException('Storage with ID "' . $id . '" not found'); |
|
| 153 | + throw new NotFoundException('Storage with ID "'.$id.'" not found'); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | $config = $this->getStorageConfigFromDBMount($mount); |
| 157 | 157 | if ($this->isApplicable($config)) { |
| 158 | 158 | return $config; |
| 159 | 159 | } else { |
| 160 | - throw new NotFoundException('Storage with ID "' . $id . '" not found'); |
|
| 160 | + throw new NotFoundException('Storage with ID "'.$id.'" not found'); |
|
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | 163 | |
@@ -380,13 +380,13 @@ discard block |
||
| 380 | 380 | $existingMount = $this->dbConfig->getMountById($id); |
| 381 | 381 | |
| 382 | 382 | if (!is_array($existingMount)) { |
| 383 | - throw new NotFoundException('Storage with ID "' . $id . '" not found while updating storage'); |
|
| 383 | + throw new NotFoundException('Storage with ID "'.$id.'" not found while updating storage'); |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | $oldStorage = $this->getStorageConfigFromDBMount($existingMount); |
| 387 | 387 | |
| 388 | 388 | if ($oldStorage->getBackend() instanceof InvalidBackend) { |
| 389 | - throw new NotFoundException('Storage with id "' . $id . '" cannot be edited due to missing backend'); |
|
| 389 | + throw new NotFoundException('Storage with id "'.$id.'" cannot be edited due to missing backend'); |
|
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | $removedUsers = array_diff($oldStorage->getApplicableUsers(), $updatedStorage->getApplicableUsers()); |
@@ -464,7 +464,7 @@ discard block |
||
| 464 | 464 | var_dump($id); |
| 465 | 465 | |
| 466 | 466 | if (!is_array($existingMount)) { |
| 467 | - throw new NotFoundException('Storage with ID "' . $id . '" not found'); |
|
| 467 | + throw new NotFoundException('Storage with ID "'.$id.'" not found'); |
|
| 468 | 468 | } |
| 469 | 469 | |
| 470 | 470 | $this->dbConfig->removeMount($id); |