@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | private function getCutoff(int $expire): \DateInterval { |
86 | 86 | $d1 = new \DateTime(); |
87 | 87 | $d2 = clone $d1; |
88 | - $d2->sub(new \DateInterval('PT' . $expire . 'S')); |
|
88 | + $d2->sub(new \DateInterval('PT'.$expire.'S')); |
|
89 | 89 | return $d2->diff($d1); |
90 | 90 | } |
91 | 91 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $values = [ |
121 | 121 | 'action' => $action, |
122 | 122 | 'occurred' => $this->timeFactory->getTime(), |
123 | - 'ip' => (string)$ipAddress, |
|
123 | + 'ip' => (string) $ipAddress, |
|
124 | 124 | 'subnet' => $ipAddress->getSubnet(), |
125 | 125 | 'metadata' => json_encode($metadata), |
126 | 126 | ]; |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | } |
157 | 157 | |
158 | 158 | $keys = $this->config->getAppKeys('bruteForce'); |
159 | - $keys = array_filter($keys, function ($key) { |
|
159 | + $keys = array_filter($keys, function($key) { |
|
160 | 160 | return str_starts_with($key, 'whitelist_'); |
161 | 161 | }); |
162 | 162 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | |
176 | 176 | $cx = explode('/', $cidr); |
177 | 177 | $addr = $cx[0]; |
178 | - $mask = (int)$cx[1]; |
|
178 | + $mask = (int) $cx[1]; |
|
179 | 179 | |
180 | 180 | // Do not compare ipv4 to ipv6 |
181 | 181 | if (($type === 4 && !filter_var($addr, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) || |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | |
188 | 188 | $valid = true; |
189 | 189 | for ($i = 0; $i < $mask; $i++) { |
190 | - $part = ord($addr[(int)($i / 8)]); |
|
191 | - $orig = ord($ip[(int)($i / 8)]); |
|
190 | + $part = ord($addr[(int) ($i / 8)]); |
|
191 | + $orig = ord($ip[(int) ($i / 8)]); |
|
192 | 192 | |
193 | 193 | $bitmask = 1 << (7 - ($i % 8)); |
194 | 194 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | } |
229 | 229 | |
230 | 230 | $ipAddress = new IpAddress($ip); |
231 | - if ($this->isIPWhitelisted((string)$ipAddress)) { |
|
231 | + if ($this->isIPWhitelisted((string) $ipAddress)) { |
|
232 | 232 | return 0; |
233 | 233 | } |
234 | 234 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | */ |
287 | 287 | public function resetDelay(string $ip, string $action, array $metadata): void { |
288 | 288 | $ipAddress = new IpAddress($ip); |
289 | - if ($this->isIPWhitelisted((string)$ipAddress)) { |
|
289 | + if ($this->isIPWhitelisted((string) $ipAddress)) { |
|
290 | 290 | return; |
291 | 291 | } |
292 | 292 |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * PHP platform. |
55 | 55 | */ |
56 | 56 | public function __construct() { |
57 | - $pow_2_53 = (float)self::POW_2_53_MINUS_1 + 1.0; |
|
57 | + $pow_2_53 = (float) self::POW_2_53_MINUS_1 + 1.0; |
|
58 | 58 | if ($this->formatUnsignedInteger($pow_2_53) !== self::POW_2_53) { |
59 | 59 | throw new \RuntimeException( |
60 | 60 | 'This class assumes floats to be double precision or "better".' |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return string Unsigned integer base-10 string |
75 | 75 | */ |
76 | - public function formatUnsignedInteger(int|float|string $number): string { |
|
76 | + public function formatUnsignedInteger(int | float | string $number): string { |
|
77 | 77 | if (is_float($number)) { |
78 | 78 | // Undo the effect of the php.ini setting 'precision'. |
79 | 79 | return number_format($number, 0, '', ''); |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @return int|float Number of bytes as number (float or int) |
99 | 99 | */ |
100 | - public function getFileSize(string $filename): int|float { |
|
100 | + public function getFileSize(string $filename): int | float { |
|
101 | 101 | $fileSize = $this->getFileSizeViaCurl($filename); |
102 | 102 | if (!is_null($fileSize)) { |
103 | 103 | return $fileSize; |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @return null|int|float Number of bytes as number (float or int) or |
118 | 118 | * null on failure. |
119 | 119 | */ |
120 | - public function getFileSizeViaCurl(string $fileName): null|int|float { |
|
120 | + public function getFileSizeViaCurl(string $fileName): null | int | float { |
|
121 | 121 | if (\OC::$server->get(IniGetWrapper::class)->getString('open_basedir') === '') { |
122 | 122 | $encodedFileName = rawurlencode($fileName); |
123 | 123 | $ch = curl_init("file:///$encodedFileName"); |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | * @return null|int|float Number of bytes as number (float or int) or |
146 | 146 | * null on failure. |
147 | 147 | */ |
148 | - public function getFileSizeViaExec(string $filename): null|int|float { |
|
148 | + public function getFileSizeViaExec(string $filename): null | int | float { |
|
149 | 149 | if (\OCP\Util::isFunctionEnabled('exec')) { |
150 | 150 | $os = strtolower(php_uname('s')); |
151 | 151 | $arg = escapeshellarg($filename); |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @return int|float Number of bytes as number (float or int). |
172 | 172 | */ |
173 | - public function getFileSizeNative(string $filename): int|float { |
|
173 | + public function getFileSizeNative(string $filename): int | float { |
|
174 | 174 | $result = filesize($filename); |
175 | 175 | if ($result < 0) { |
176 | 176 | // For file sizes between 2 GiB and 4 GiB, filesize() will return a |
@@ -194,14 +194,14 @@ discard block |
||
194 | 194 | if (\OCP\Util::isFunctionEnabled('exec')) { |
195 | 195 | $os = strtolower(php_uname('s')); |
196 | 196 | if (str_contains($os, 'linux')) { |
197 | - return (int)($this->exec('stat -c %Y ' . escapeshellarg($fullPath)) ?? -1); |
|
197 | + return (int) ($this->exec('stat -c %Y '.escapeshellarg($fullPath)) ?? -1); |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 | } |
201 | 201 | return $result; |
202 | 202 | } |
203 | 203 | |
204 | - protected function exec(string $cmd): null|int|float { |
|
204 | + protected function exec(string $cmd): null | int | float { |
|
205 | 205 | $result = trim(exec($cmd)); |
206 | 206 | return ctype_digit($result) ? 0 + $result : null; |
207 | 207 | } |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | $rootView = new View(); |
55 | 55 | $user = \OC::$server->getUserSession()->getUser(); |
56 | 56 | Filesystem::initMountPoints($user->getUID()); |
57 | - if (!$rootView->file_exists('/' . $user->getUID() . '/cache')) { |
|
58 | - $rootView->mkdir('/' . $user->getUID() . '/cache'); |
|
57 | + if (!$rootView->file_exists('/'.$user->getUID().'/cache')) { |
|
58 | + $rootView->mkdir('/'.$user->getUID().'/cache'); |
|
59 | 59 | } |
60 | - $this->storage = new View('/' . $user->getUID() . '/cache'); |
|
60 | + $this->storage = new View('/'.$user->getUID().'/cache'); |
|
61 | 61 | return $this->storage; |
62 | 62 | } else { |
63 | 63 | \OC::$server->get(LoggerInterface::class)->error('Can\'t get cache storage, user not logged in', ['app' => 'core']); |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | |
113 | 113 | // use part file to prevent hasKey() to find the key |
114 | 114 | // while it is being written |
115 | - $keyPart = $key . '.' . $uniqueId . '.part'; |
|
115 | + $keyPart = $key.'.'.$uniqueId.'.part'; |
|
116 | 116 | if ($storage and $storage->file_put_contents($keyPart, $value)) { |
117 | 117 | if ($ttl === 0) { |
118 | 118 | $ttl = 86400; // 60*60*24 |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | if (is_resource($dh)) { |
162 | 162 | while (($file = readdir($dh)) !== false) { |
163 | 163 | if ($file != '.' and $file != '..' and ($prefix === '' || str_starts_with($file, $prefix))) { |
164 | - $storage->unlink('/' . $file); |
|
164 | + $storage->unlink('/'.$file); |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | } |
@@ -186,17 +186,17 @@ discard block |
||
186 | 186 | while (($file = readdir($dh)) !== false) { |
187 | 187 | if ($file != '.' and $file != '..') { |
188 | 188 | try { |
189 | - $mtime = $storage->filemtime('/' . $file); |
|
189 | + $mtime = $storage->filemtime('/'.$file); |
|
190 | 190 | if ($mtime < $now) { |
191 | - $storage->unlink('/' . $file); |
|
191 | + $storage->unlink('/'.$file); |
|
192 | 192 | } |
193 | 193 | } catch (\OCP\Lock\LockedException $e) { |
194 | 194 | // ignore locked chunks |
195 | - \OC::$server->getLogger()->debug('Could not cleanup locked chunk "' . $file . '"', ['app' => 'core']); |
|
195 | + \OC::$server->getLogger()->debug('Could not cleanup locked chunk "'.$file.'"', ['app' => 'core']); |
|
196 | 196 | } catch (\OCP\Files\ForbiddenException $e) { |
197 | - \OC::$server->getLogger()->debug('Could not cleanup forbidden chunk "' . $file . '"', ['app' => 'core']); |
|
197 | + \OC::$server->getLogger()->debug('Could not cleanup forbidden chunk "'.$file.'"', ['app' => 'core']); |
|
198 | 198 | } catch (\OCP\Files\LockNotAcquiredException $e) { |
199 | - \OC::$server->getLogger()->debug('Could not cleanup locked chunk "' . $file . '"', ['app' => 'core']); |
|
199 | + \OC::$server->getLogger()->debug('Could not cleanup locked chunk "'.$file.'"', ['app' => 'core']); |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | } |
@@ -132,14 +132,14 @@ discard block |
||
132 | 132 | OC_App::loadApps(['filesystem']); |
133 | 133 | $prevLogging = Filesystem::logWarningWhenAddingStorageWrapper(false); |
134 | 134 | |
135 | - Filesystem::addStorageWrapper('mount_options', function ($mountPoint, IStorage $storage, IMountPoint $mount) { |
|
135 | + Filesystem::addStorageWrapper('mount_options', function($mountPoint, IStorage $storage, IMountPoint $mount) { |
|
136 | 136 | if ($storage->instanceOfStorage(Common::class)) { |
137 | 137 | $storage->setMountOptions($mount->getOptions()); |
138 | 138 | } |
139 | 139 | return $storage; |
140 | 140 | }); |
141 | 141 | |
142 | - Filesystem::addStorageWrapper('enable_sharing', function ($mountPoint, IStorage $storage, IMountPoint $mount) { |
|
142 | + Filesystem::addStorageWrapper('enable_sharing', function($mountPoint, IStorage $storage, IMountPoint $mount) { |
|
143 | 143 | if (!$mount->getOption('enable_sharing', true)) { |
144 | 144 | return new PermissionsMask([ |
145 | 145 | 'storage' => $storage, |
@@ -150,21 +150,21 @@ discard block |
||
150 | 150 | }); |
151 | 151 | |
152 | 152 | // install storage availability wrapper, before most other wrappers |
153 | - Filesystem::addStorageWrapper('oc_availability', function ($mountPoint, IStorage $storage) { |
|
153 | + Filesystem::addStorageWrapper('oc_availability', function($mountPoint, IStorage $storage) { |
|
154 | 154 | if (!$storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage') && !$storage->isLocal()) { |
155 | 155 | return new Availability(['storage' => $storage]); |
156 | 156 | } |
157 | 157 | return $storage; |
158 | 158 | }); |
159 | 159 | |
160 | - Filesystem::addStorageWrapper('oc_encoding', function ($mountPoint, IStorage $storage, IMountPoint $mount) { |
|
160 | + Filesystem::addStorageWrapper('oc_encoding', function($mountPoint, IStorage $storage, IMountPoint $mount) { |
|
161 | 161 | if ($mount->getOption('encoding_compatibility', false) && !$storage->instanceOfStorage('\OCA\Files_Sharing\SharedStorage')) { |
162 | 162 | return new Encoding(['storage' => $storage]); |
163 | 163 | } |
164 | 164 | return $storage; |
165 | 165 | }); |
166 | 166 | |
167 | - Filesystem::addStorageWrapper('oc_quota', function ($mountPoint, $storage) { |
|
167 | + Filesystem::addStorageWrapper('oc_quota', function($mountPoint, $storage) { |
|
168 | 168 | // set up quota for home storages, even for other users |
169 | 169 | // which can happen when using sharing |
170 | 170 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | if ($storage->instanceOfStorage(HomeObjectStoreStorage::class) || $storage->instanceOfStorage(Home::class)) { |
175 | 175 | if (is_object($storage->getUser())) { |
176 | 176 | $user = $storage->getUser(); |
177 | - return new Quota(['storage' => $storage, 'quotaCallback' => function () use ($user) { |
|
177 | + return new Quota(['storage' => $storage, 'quotaCallback' => function() use ($user) { |
|
178 | 178 | return OC_Util::getUserQuota($user); |
179 | 179 | }, 'root' => 'files']); |
180 | 180 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | return $storage; |
184 | 184 | }); |
185 | 185 | |
186 | - Filesystem::addStorageWrapper('readonly', function ($mountPoint, IStorage $storage, IMountPoint $mount) { |
|
186 | + Filesystem::addStorageWrapper('readonly', function($mountPoint, IStorage $storage, IMountPoint $mount) { |
|
187 | 187 | /* |
188 | 188 | * Do not allow any operations that modify the storage |
189 | 189 | */ |
@@ -220,8 +220,8 @@ discard block |
||
220 | 220 | |
221 | 221 | $previouslySetupProviders = $this->setupUserMountProviders[$user->getUID()]; |
222 | 222 | |
223 | - $this->setupForUserWith($user, function () use ($user) { |
|
224 | - $this->mountProviderCollection->addMountForUser($user, $this->mountManager, function ( |
|
223 | + $this->setupForUserWith($user, function() use ($user) { |
|
224 | + $this->mountProviderCollection->addMountForUser($user, $this->mountManager, function( |
|
225 | 225 | IMountProvider $provider |
226 | 226 | ) use ($user) { |
227 | 227 | return !in_array(get_class($provider), $this->setupUserMountProviders[$user->getUID()]); |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | |
253 | 253 | Filesystem::logWarningWhenAddingStorageWrapper($prevLogging); |
254 | 254 | |
255 | - $userDir = '/' . $user->getUID() . '/files'; |
|
255 | + $userDir = '/'.$user->getUID().'/files'; |
|
256 | 256 | |
257 | 257 | Filesystem::initInternal($userDir); |
258 | 258 | |
@@ -272,11 +272,11 @@ discard block |
||
272 | 272 | } else { |
273 | 273 | $this->mountManager->addMount(new MountPoint( |
274 | 274 | new NullStorage([]), |
275 | - '/' . $user->getUID() |
|
275 | + '/'.$user->getUID() |
|
276 | 276 | )); |
277 | 277 | $this->mountManager->addMount(new MountPoint( |
278 | 278 | new NullStorage([]), |
279 | - '/' . $user->getUID() . '/files' |
|
279 | + '/'.$user->getUID().'/files' |
|
280 | 280 | )); |
281 | 281 | $this->setupUsersComplete[] = $user->getUID(); |
282 | 282 | } |
@@ -291,16 +291,16 @@ discard block |
||
291 | 291 | */ |
292 | 292 | private function afterUserFullySetup(IUser $user, array $previouslySetupProviders): void { |
293 | 293 | $this->eventLogger->start('fs:setup:user:full:post', 'Housekeeping after user is setup'); |
294 | - $userRoot = '/' . $user->getUID() . '/'; |
|
294 | + $userRoot = '/'.$user->getUID().'/'; |
|
295 | 295 | $mounts = $this->mountManager->getAll(); |
296 | - $mounts = array_filter($mounts, function (IMountPoint $mount) use ($userRoot) { |
|
296 | + $mounts = array_filter($mounts, function(IMountPoint $mount) use ($userRoot) { |
|
297 | 297 | return str_starts_with($mount->getMountPoint(), $userRoot); |
298 | 298 | }); |
299 | - $allProviders = array_map(function (IMountProvider $provider) { |
|
299 | + $allProviders = array_map(function(IMountProvider $provider) { |
|
300 | 300 | return get_class($provider); |
301 | 301 | }, $this->mountProviderCollection->getProviders()); |
302 | 302 | $newProviders = array_diff($allProviders, $previouslySetupProviders); |
303 | - $mounts = array_filter($mounts, function (IMountPoint $mount) use ($previouslySetupProviders) { |
|
303 | + $mounts = array_filter($mounts, function(IMountPoint $mount) use ($previouslySetupProviders) { |
|
304 | 304 | return !in_array($mount->getMountProvider(), $previouslySetupProviders); |
305 | 305 | }); |
306 | 306 | $this->userMountCache->registerMounts($user, $mounts, $newProviders); |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | \OC_Hook::emit('OC_Filesystem', 'post_initMountPoints', ['user' => $user->getUID()]); |
331 | 331 | $this->eventLogger->end('fs:setup:user:post-init-mountpoint'); |
332 | 332 | |
333 | - $userDir = '/' . $user->getUID() . '/files'; |
|
333 | + $userDir = '/'.$user->getUID().'/files'; |
|
334 | 334 | $this->eventLogger->start('fs:setup:user:setup-hook', 'setup legacy hook'); |
335 | 335 | OC_Hook::emit('OC_Filesystem', 'setup', ['user' => $user->getUID(), 'user_dir' => $userDir]); |
336 | 336 | $this->eventLogger->end('fs:setup:user:setup-hook'); |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | } else { |
374 | 374 | return null; |
375 | 375 | } |
376 | - } elseif (str_starts_with($path, '/appdata_' . \OC_Util::getInstanceId()) || str_starts_with($path, '/files_external/')) { |
|
376 | + } elseif (str_starts_with($path, '/appdata_'.\OC_Util::getInstanceId()) || str_starts_with($path, '/files_external/')) { |
|
377 | 377 | return null; |
378 | 378 | } else { |
379 | 379 | [, $userId] = explode('/', $path); |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | } |
403 | 403 | |
404 | 404 | // for the user's home folder, and includes children we need everything always |
405 | - if (rtrim($path) === "/" . $user->getUID() . "/files" && $includeChildren) { |
|
405 | + if (rtrim($path) === "/".$user->getUID()."/files" && $includeChildren) { |
|
406 | 406 | $this->setupForUser($user); |
407 | 407 | return; |
408 | 408 | } |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | $setupProviders[] = $cachedMount->getMountProvider(); |
433 | 433 | $mounts = $this->mountProviderCollection->getUserMountsForProviderClasses($user, [$cachedMount->getMountProvider()]); |
434 | 434 | } else { |
435 | - $this->logger->debug("mount at " . $cachedMount->getMountPoint() . " has no provider set, performing full setup"); |
|
435 | + $this->logger->debug("mount at ".$cachedMount->getMountPoint()." has no provider set, performing full setup"); |
|
436 | 436 | $this->eventLogger->end('fs:setup:user:path:find'); |
437 | 437 | $this->setupForUser($user); |
438 | 438 | $this->eventLogger->end('fs:setup:user:path'); |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | $subCachedMounts = $this->userMountCache->getMountsInPath($user, $path); |
445 | 445 | $this->eventLogger->end('fs:setup:user:path:find'); |
446 | 446 | |
447 | - $needsFullSetup = array_reduce($subCachedMounts, function (bool $needsFullSetup, ICachedMountInfo $cachedMountInfo) { |
|
447 | + $needsFullSetup = array_reduce($subCachedMounts, function(bool $needsFullSetup, ICachedMountInfo $cachedMountInfo) { |
|
448 | 448 | return $needsFullSetup || $cachedMountInfo->getMountProvider() === ''; |
449 | 449 | }, false); |
450 | 450 | |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | |
469 | 469 | if (count($mounts)) { |
470 | 470 | $this->userMountCache->registerMounts($user, $mounts, $currentProviders); |
471 | - $this->setupForUserWith($user, function () use ($mounts) { |
|
471 | + $this->setupForUserWith($user, function() use ($mounts) { |
|
472 | 472 | array_walk($mounts, [$this->mountManager, 'addMount']); |
473 | 473 | }); |
474 | 474 | } elseif (!$this->isSetupStarted($user)) { |
@@ -507,12 +507,12 @@ discard block |
||
507 | 507 | return; |
508 | 508 | } |
509 | 509 | |
510 | - $this->eventLogger->start('fs:setup:user:providers', "Setup filesystem for " . implode(', ', $providers)); |
|
510 | + $this->eventLogger->start('fs:setup:user:providers', "Setup filesystem for ".implode(', ', $providers)); |
|
511 | 511 | |
512 | 512 | $this->oneTimeUserSetup($user); |
513 | 513 | |
514 | 514 | // home providers are always used |
515 | - $providers = array_filter($providers, function (string $provider) { |
|
515 | + $providers = array_filter($providers, function(string $provider) { |
|
516 | 516 | return !is_subclass_of($provider, IHomeMountProvider::class); |
517 | 517 | }); |
518 | 518 | |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | } |
536 | 536 | |
537 | 537 | $this->userMountCache->registerMounts($user, $mounts, $providers); |
538 | - $this->setupForUserWith($user, function () use ($mounts) { |
|
538 | + $this->setupForUserWith($user, function() use ($mounts) { |
|
539 | 539 | array_walk($mounts, [$this->mountManager, 'addMount']); |
540 | 540 | }); |
541 | 541 | $this->eventLogger->end('fs:setup:user:providers'); |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | private function listenForNewMountProviders() { |
558 | 558 | if (!$this->listeningForProviders) { |
559 | 559 | $this->listeningForProviders = true; |
560 | - $this->mountProviderCollection->listen('\OC\Files\Config', 'registerMountProvider', function ( |
|
560 | + $this->mountProviderCollection->listen('\OC\Files\Config', 'registerMountProvider', function( |
|
561 | 561 | IMountProvider $provider |
562 | 562 | ) { |
563 | 563 | foreach ($this->setupUsers as $userId) { |
@@ -575,16 +575,16 @@ discard block |
||
575 | 575 | // note that this event handling is intentionally pessimistic |
576 | 576 | // clearing the cache to often is better than not enough |
577 | 577 | |
578 | - $this->eventDispatcher->addListener(UserAddedEvent::class, function (UserAddedEvent $event) { |
|
578 | + $this->eventDispatcher->addListener(UserAddedEvent::class, function(UserAddedEvent $event) { |
|
579 | 579 | $this->cache->remove($event->getUser()->getUID()); |
580 | 580 | }); |
581 | - $this->eventDispatcher->addListener(UserRemovedEvent::class, function (UserRemovedEvent $event) { |
|
581 | + $this->eventDispatcher->addListener(UserRemovedEvent::class, function(UserRemovedEvent $event) { |
|
582 | 582 | $this->cache->remove($event->getUser()->getUID()); |
583 | 583 | }); |
584 | - $this->eventDispatcher->addListener(ShareCreatedEvent::class, function (ShareCreatedEvent $event) { |
|
584 | + $this->eventDispatcher->addListener(ShareCreatedEvent::class, function(ShareCreatedEvent $event) { |
|
585 | 585 | $this->cache->remove($event->getShare()->getSharedWith()); |
586 | 586 | }); |
587 | - $this->eventDispatcher->addListener(InvalidateMountCacheEvent::class, function (InvalidateMountCacheEvent $event |
|
587 | + $this->eventDispatcher->addListener(InvalidateMountCacheEvent::class, function(InvalidateMountCacheEvent $event |
|
588 | 588 | ) { |
589 | 589 | if ($user = $event->getUser()) { |
590 | 590 | $this->cache->remove($user->getUID()); |
@@ -601,7 +601,7 @@ discard block |
||
601 | 601 | ]; |
602 | 602 | |
603 | 603 | foreach ($genericEvents as $genericEvent) { |
604 | - $this->eventDispatcher->addListener($genericEvent, function ($event) { |
|
604 | + $this->eventDispatcher->addListener($genericEvent, function($event) { |
|
605 | 605 | $this->cache->clear(); |
606 | 606 | }); |
607 | 607 | } |
@@ -79,11 +79,11 @@ discard block |
||
79 | 79 | public function registerMounts(IUser $user, array $mounts, array $mountProviderClasses = null) { |
80 | 80 | $this->eventLogger->start('fs:setup:user:register', 'Registering mounts for user'); |
81 | 81 | // filter out non-proper storages coming from unit tests |
82 | - $mounts = array_filter($mounts, function (IMountPoint $mount) { |
|
82 | + $mounts = array_filter($mounts, function(IMountPoint $mount) { |
|
83 | 83 | return $mount instanceof SharedMount || ($mount->getStorage() && $mount->getStorage()->getCache()); |
84 | 84 | }); |
85 | 85 | /** @var ICachedMountInfo[] $newMounts */ |
86 | - $newMounts = array_map(function (IMountPoint $mount) use ($user) { |
|
86 | + $newMounts = array_map(function(IMountPoint $mount) use ($user) { |
|
87 | 87 | // filter out any storages which aren't scanned yet since we aren't interested in files from those storages (yet) |
88 | 88 | if ($mount->getStorageRootId() === -1) { |
89 | 89 | return null; |
@@ -92,25 +92,25 @@ discard block |
||
92 | 92 | } |
93 | 93 | }, $mounts); |
94 | 94 | $newMounts = array_values(array_filter($newMounts)); |
95 | - $newMountKeys = array_map(function (ICachedMountInfo $mount) { |
|
96 | - return $mount->getRootId() . '::' . $mount->getMountPoint(); |
|
95 | + $newMountKeys = array_map(function(ICachedMountInfo $mount) { |
|
96 | + return $mount->getRootId().'::'.$mount->getMountPoint(); |
|
97 | 97 | }, $newMounts); |
98 | 98 | $newMounts = array_combine($newMountKeys, $newMounts); |
99 | 99 | |
100 | 100 | $cachedMounts = $this->getMountsForUser($user); |
101 | 101 | if (is_array($mountProviderClasses)) { |
102 | - $cachedMounts = array_filter($cachedMounts, function (ICachedMountInfo $mountInfo) use ($mountProviderClasses, $newMounts) { |
|
102 | + $cachedMounts = array_filter($cachedMounts, function(ICachedMountInfo $mountInfo) use ($mountProviderClasses, $newMounts) { |
|
103 | 103 | // for existing mounts that didn't have a mount provider set |
104 | 104 | // we still want the ones that map to new mounts |
105 | - $mountKey = $mountInfo->getRootId() . '::' . $mountInfo->getMountPoint(); |
|
105 | + $mountKey = $mountInfo->getRootId().'::'.$mountInfo->getMountPoint(); |
|
106 | 106 | if ($mountInfo->getMountProvider() === '' && isset($newMounts[$mountKey])) { |
107 | 107 | return true; |
108 | 108 | } |
109 | 109 | return in_array($mountInfo->getMountProvider(), $mountProviderClasses); |
110 | 110 | }); |
111 | 111 | } |
112 | - $cachedRootKeys = array_map(function (ICachedMountInfo $mount) { |
|
113 | - return $mount->getRootId() . '::' . $mount->getMountPoint(); |
|
112 | + $cachedRootKeys = array_map(function(ICachedMountInfo $mount) { |
|
113 | + return $mount->getRootId().'::'.$mount->getMountPoint(); |
|
114 | 114 | }, $cachedMounts); |
115 | 115 | $cachedMounts = array_combine($cachedRootKeys, $cachedMounts); |
116 | 116 | |
@@ -162,11 +162,11 @@ discard block |
||
162 | 162 | private function findChangedMounts(array $newMounts, array $cachedMounts) { |
163 | 163 | $new = []; |
164 | 164 | foreach ($newMounts as $mount) { |
165 | - $new[$mount->getRootId() . '::' . $mount->getMountPoint()] = $mount; |
|
165 | + $new[$mount->getRootId().'::'.$mount->getMountPoint()] = $mount; |
|
166 | 166 | } |
167 | 167 | $changed = []; |
168 | 168 | foreach ($cachedMounts as $cachedMount) { |
169 | - $key = $cachedMount->getRootId() . '::' . $cachedMount->getMountPoint(); |
|
169 | + $key = $cachedMount->getRootId().'::'.$cachedMount->getMountPoint(); |
|
170 | 170 | if (isset($new[$key])) { |
171 | 171 | $newMount = $new[$key]; |
172 | 172 | if ( |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | ], ['root_id', 'user_id', 'mount_point']); |
195 | 195 | } else { |
196 | 196 | // in some cases this is legitimate, like orphaned shares |
197 | - $this->logger->debug('Could not get storage info for mount at ' . $mount->getMountPoint()); |
|
197 | + $this->logger->debug('Could not get storage info for mount at '.$mount->getMountPoint()); |
|
198 | 198 | } |
199 | 199 | } |
200 | 200 | |
@@ -229,12 +229,12 @@ discard block |
||
229 | 229 | } |
230 | 230 | $mount_id = $row['mount_id']; |
231 | 231 | if (!is_null($mount_id)) { |
232 | - $mount_id = (int)$mount_id; |
|
232 | + $mount_id = (int) $mount_id; |
|
233 | 233 | } |
234 | 234 | return new CachedMountInfo( |
235 | 235 | $user, |
236 | - (int)$row['storage_id'], |
|
237 | - (int)$row['root_id'], |
|
236 | + (int) $row['storage_id'], |
|
237 | + (int) $row['root_id'], |
|
238 | 238 | $row['mount_point'], |
239 | 239 | $row['mount_provider_class'] ?? '', |
240 | 240 | $mount_id, |
@@ -322,12 +322,12 @@ discard block |
||
322 | 322 | |
323 | 323 | if (is_array($row)) { |
324 | 324 | $this->cacheInfoCache[$fileId] = [ |
325 | - (int)$row['storage'], |
|
326 | - (string)$row['path'], |
|
327 | - (int)$row['mimetype'] |
|
325 | + (int) $row['storage'], |
|
326 | + (string) $row['path'], |
|
327 | + (int) $row['mimetype'] |
|
328 | 328 | ]; |
329 | 329 | } else { |
330 | - throw new NotFoundException('File with id "' . $fileId . '" not found'); |
|
330 | + throw new NotFoundException('File with id "'.$fileId.'" not found'); |
|
331 | 331 | } |
332 | 332 | } |
333 | 333 | return $this->cacheInfoCache[$fileId]; |
@@ -359,17 +359,17 @@ discard block |
||
359 | 359 | $rows = $result->fetchAll(); |
360 | 360 | $result->closeCursor(); |
361 | 361 | // filter mounts that are from the same storage but a different directory |
362 | - $filteredMounts = array_filter($rows, function (array $row) use ($internalPath, $fileId) { |
|
363 | - if ($fileId === (int)$row['root_id']) { |
|
362 | + $filteredMounts = array_filter($rows, function(array $row) use ($internalPath, $fileId) { |
|
363 | + if ($fileId === (int) $row['root_id']) { |
|
364 | 364 | return true; |
365 | 365 | } |
366 | 366 | $internalMountPath = $row['path'] ?? ''; |
367 | 367 | |
368 | - return $internalMountPath === '' || substr($internalPath, 0, strlen($internalMountPath) + 1) === $internalMountPath . '/'; |
|
368 | + return $internalMountPath === '' || substr($internalPath, 0, strlen($internalMountPath) + 1) === $internalMountPath.'/'; |
|
369 | 369 | }); |
370 | 370 | |
371 | 371 | $filteredMounts = array_filter(array_map([$this, 'dbRowToMountInfo'], $filteredMounts)); |
372 | - return array_map(function (ICachedMountInfo $mount) use ($internalPath) { |
|
372 | + return array_map(function(ICachedMountInfo $mount) use ($internalPath) { |
|
373 | 373 | return new CachedMountFileInfo( |
374 | 374 | $mount->getUser(), |
375 | 375 | $mount->getStorageId(), |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | $slash |
428 | 428 | ); |
429 | 429 | |
430 | - $userIds = array_map(function (IUser $user) { |
|
430 | + $userIds = array_map(function(IUser $user) { |
|
431 | 431 | return $user->getUID(); |
432 | 432 | }, $users); |
433 | 433 | |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | |
459 | 459 | public function getMountForPath(IUser $user, string $path): ICachedMountInfo { |
460 | 460 | $mounts = $this->getMountsForUser($user); |
461 | - $mountPoints = array_map(function (ICachedMountInfo $mount) { |
|
461 | + $mountPoints = array_map(function(ICachedMountInfo $mount) { |
|
462 | 462 | return $mount->getMountPoint(); |
463 | 463 | }, $mounts); |
464 | 464 | $mounts = array_combine($mountPoints, $mounts); |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | // walk up the directory tree until we find a path that has a mountpoint set |
468 | 468 | // the loop will return if a mountpoint is found or break if none are found |
469 | 469 | while (true) { |
470 | - $mountPoint = $current . '/'; |
|
470 | + $mountPoint = $current.'/'; |
|
471 | 471 | if (isset($mounts[$mountPoint])) { |
472 | 472 | return $mounts[$mountPoint]; |
473 | 473 | } elseif ($current === '') { |
@@ -480,13 +480,13 @@ discard block |
||
480 | 480 | } |
481 | 481 | } |
482 | 482 | |
483 | - throw new NotFoundException("No cached mount for path " . $path); |
|
483 | + throw new NotFoundException("No cached mount for path ".$path); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | public function getMountsInPath(IUser $user, string $path): array { |
487 | - $path = rtrim($path, '/') . '/'; |
|
487 | + $path = rtrim($path, '/').'/'; |
|
488 | 488 | $mounts = $this->getMountsForUser($user); |
489 | - return array_filter($mounts, function (ICachedMountInfo $mount) use ($path) { |
|
489 | + return array_filter($mounts, function(ICachedMountInfo $mount) use ($path) { |
|
490 | 490 | return $mount->getMountPoint() !== $path && str_starts_with($mount->getMountPoint(), $path); |
491 | 491 | }); |
492 | 492 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | use OCP\IUserSession; |
51 | 51 | |
52 | 52 | class Filesystem { |
53 | - private static ?Mount\Manager $mounts = null; |
|
53 | + private static ? Mount\Manager $mounts = null; |
|
54 | 54 | |
55 | 55 | public static bool $loaded = false; |
56 | 56 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | private static ?CappedMemoryCache $normalizedPathCache = null; |
60 | 60 | |
61 | 61 | /** @var string[]|null */ |
62 | - private static ?array $blacklist = null; |
|
62 | + private static ? array $blacklist = null; |
|
63 | 63 | |
64 | 64 | /** |
65 | 65 | * classname which used for hooks handling |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | public const signal_param_mount_type = 'mounttype'; |
179 | 179 | public const signal_param_users = 'users'; |
180 | 180 | |
181 | - private static ?\OC\Files\Storage\StorageFactory $loader = null; |
|
181 | + private static ? \OC\Files\Storage\StorageFactory $loader = null; |
|
182 | 182 | |
183 | 183 | private static bool $logWarningWhenAddingStorageWrapper = true; |
184 | 184 | |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | return [$mount->getStorage(), rtrim($mount->getInternalPath($path), '/')]; |
308 | 308 | } |
309 | 309 | |
310 | - public static function init(string|IUser|null $user, string $root): bool { |
|
310 | + public static function init(string | IUser | null $user, string $root): bool { |
|
311 | 311 | if (self::$defaultInstance) { |
312 | 312 | return false; |
313 | 313 | } |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | self::$defaultInstance = new View($root); |
328 | 328 | /** @var IEventDispatcher $eventDispatcher */ |
329 | 329 | $eventDispatcher = \OC::$server->get(IEventDispatcher::class); |
330 | - $eventDispatcher->addListener(FilesystemTornDownEvent::class, function () { |
|
330 | + $eventDispatcher->addListener(FilesystemTornDownEvent::class, function() { |
|
331 | 331 | self::$defaultInstance = null; |
332 | 332 | self::$loaded = false; |
333 | 333 | }); |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | * |
351 | 351 | * @throws \OC\User\NoUserException if the user is not available |
352 | 352 | */ |
353 | - public static function initMountPoints(string|IUser|null $user = ''): void { |
|
353 | + public static function initMountPoints(string | IUser | null $user = ''): void { |
|
354 | 354 | /** @var IUserManager $userManager */ |
355 | 355 | $userManager = \OC::$server->get(IUserManager::class); |
356 | 356 | |
@@ -373,7 +373,7 @@ discard block |
||
373 | 373 | $session = \OC::$server->get(IUserSession::class); |
374 | 374 | $user = $session->getUser(); |
375 | 375 | if ($user) { |
376 | - $userDir = '/' . $user->getUID() . '/files'; |
|
376 | + $userDir = '/'.$user->getUID().'/files'; |
|
377 | 377 | self::initInternal($userDir); |
378 | 378 | } |
379 | 379 | } |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | * we need this because we can't know if a file is stored local or not from |
422 | 422 | * outside the filestorage and for some purposes a local file is needed |
423 | 423 | */ |
424 | - public static function getLocalFile(string $path): string|false { |
|
424 | + public static function getLocalFile(string $path): string | false { |
|
425 | 425 | return self::$defaultInstance->getLocalFile($path); |
426 | 426 | } |
427 | 427 | |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | * @return string |
433 | 433 | */ |
434 | 434 | public static function getLocalPath($path) { |
435 | - $datadir = \OC_User::getHome(\OC_User::getUser()) . '/files'; |
|
435 | + $datadir = \OC_User::getHome(\OC_User::getUser()).'/files'; |
|
436 | 436 | $newpath = $path; |
437 | 437 | if (strncmp($newpath, $datadir, strlen($datadir)) == 0) { |
438 | 438 | $newpath = substr($path, strlen($datadir)); |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | public static function isValidPath($path) { |
450 | 450 | $path = self::normalizePath($path); |
451 | 451 | if (!$path || $path[0] !== '/') { |
452 | - $path = '/' . $path; |
|
452 | + $path = '/'.$path; |
|
453 | 453 | } |
454 | 454 | if (str_contains($path, '/../') || strrchr($path, '/') === '/..') { |
455 | 455 | return false; |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | * @param string $path |
585 | 585 | * @throws \OCP\Files\InvalidPathException |
586 | 586 | */ |
587 | - public static function toTmpFile($path): string|false { |
|
587 | + public static function toTmpFile($path): string | false { |
|
588 | 588 | return self::$defaultInstance->toTmpFile($path); |
589 | 589 | } |
590 | 590 | |
@@ -652,7 +652,7 @@ discard block |
||
652 | 652 | * conversion should get removed as soon as all existing |
653 | 653 | * function calls have been fixed. |
654 | 654 | */ |
655 | - $path = (string)$path; |
|
655 | + $path = (string) $path; |
|
656 | 656 | |
657 | 657 | if ($path === '') { |
658 | 658 | return '/'; |
@@ -674,13 +674,13 @@ discard block |
||
674 | 674 | } |
675 | 675 | |
676 | 676 | //add leading slash, if it is already there we strip it anyway |
677 | - $path = '/' . $path; |
|
677 | + $path = '/'.$path; |
|
678 | 678 | |
679 | 679 | $patterns = [ |
680 | - '#\\\\#s', // no windows style '\\' slashes |
|
680 | + '#\\\\#s', // no windows style '\\' slashes |
|
681 | 681 | '#/\.(/\.)*/#s', // remove '/./' |
682 | - '#\//+#s', // remove sequence of slashes |
|
683 | - '#/\.$#s', // remove trailing '/.' |
|
682 | + '#\//+#s', // remove sequence of slashes |
|
683 | + '#/\.$#s', // remove trailing '/.' |
|
684 | 684 | ]; |
685 | 685 | |
686 | 686 | do { |
@@ -760,7 +760,7 @@ discard block |
||
760 | 760 | /** |
761 | 761 | * get the ETag for a file or folder |
762 | 762 | */ |
763 | - public static function getETag(string $path): string|false { |
|
763 | + public static function getETag(string $path): string | false { |
|
764 | 764 | return self::$defaultInstance->getETag($path); |
765 | 765 | } |
766 | 766 | } |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | public function getFullPath($path) { |
69 | 69 | $path = $this->normalizePath($path); |
70 | 70 | if (!$this->isValidPath($path)) { |
71 | - throw new NotPermittedException('Invalid path "' . $path . '"'); |
|
71 | + throw new NotPermittedException('Invalid path "'.$path.'"'); |
|
72 | 72 | } |
73 | - return $this->path . $path; |
|
73 | + return $this->path.$path; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @return bool |
89 | 89 | */ |
90 | 90 | public function isSubNode($node) { |
91 | - return str_starts_with($node->getPath(), $this->path . '/'); |
|
91 | + return str_starts_with($node->getPath(), $this->path.'/'); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | public function getDirectoryListing() { |
101 | 101 | $folderContent = $this->view->getDirectoryContent($this->path, '', $this->getFileInfo(false)); |
102 | 102 | |
103 | - return array_map(function (FileInfo $info) { |
|
103 | + return array_map(function(FileInfo $info) { |
|
104 | 104 | if ($info->getMimetype() === FileInfo::MIMETYPE_FOLDER) { |
105 | 105 | return new Folder($this->root, $this->view, $info->getPath(), $info, $this); |
106 | 106 | } else { |
@@ -163,14 +163,14 @@ discard block |
||
163 | 163 | $nonExisting = new NonExistingFolder($this->root, $this->view, $fullPath); |
164 | 164 | $this->sendHooks(['preWrite', 'preCreate'], [$nonExisting]); |
165 | 165 | if (!$this->view->mkdir($fullPath)) { |
166 | - throw new NotPermittedException('Could not create folder "' . $fullPath . '"'); |
|
166 | + throw new NotPermittedException('Could not create folder "'.$fullPath.'"'); |
|
167 | 167 | } |
168 | 168 | $parent = dirname($fullPath) === $this->getPath() ? $this : null; |
169 | 169 | $node = new Folder($this->root, $this->view, $fullPath, null, $parent); |
170 | 170 | $this->sendHooks(['postWrite', 'postCreate'], [$node]); |
171 | 171 | return $node; |
172 | 172 | } else { |
173 | - throw new NotPermittedException('No create permission for folder "' . $path . '"'); |
|
173 | + throw new NotPermittedException('No create permission for folder "'.$path.'"'); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
@@ -194,13 +194,13 @@ discard block |
||
194 | 194 | $result = $this->view->touch($fullPath); |
195 | 195 | } |
196 | 196 | if ($result === false) { |
197 | - throw new NotPermittedException('Could not create path "' . $fullPath . '"'); |
|
197 | + throw new NotPermittedException('Could not create path "'.$fullPath.'"'); |
|
198 | 198 | } |
199 | 199 | $node = new File($this->root, $this->view, $fullPath, null, $this); |
200 | 200 | $this->sendHooks(['postWrite', 'postCreate'], [$node]); |
201 | 201 | return $node; |
202 | 202 | } |
203 | - throw new NotPermittedException('No create permission for path "' . $path . '"'); |
|
203 | + throw new NotPermittedException('No create permission for path "'.$path.'"'); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | private function queryFromOperator(ISearchOperator $operator, string $uid = null, int $limit = 0, int $offset = 0): ISearchQuery { |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | */ |
223 | 223 | public function search($query) { |
224 | 224 | if (is_string($query)) { |
225 | - $query = $this->queryFromOperator(new SearchComparison(ISearchComparison::COMPARE_LIKE, 'name', '%' . $query . '%')); |
|
225 | + $query = $this->queryFromOperator(new SearchComparison(ISearchComparison::COMPARE_LIKE, 'name', '%'.$query.'%')); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | // search is handled by a single query covering all caches that this folder contains |
@@ -239,22 +239,22 @@ discard block |
||
239 | 239 | $resultsPerCache = $searchHelper->searchInCaches($query, $caches); |
240 | 240 | |
241 | 241 | // loop through all results per-cache, constructing the FileInfo object from the CacheEntry and merge them all |
242 | - $files = array_merge(...array_map(function (array $results, string $relativeMountPoint) use ($mountByMountPoint) { |
|
242 | + $files = array_merge(...array_map(function(array $results, string $relativeMountPoint) use ($mountByMountPoint) { |
|
243 | 243 | $mount = $mountByMountPoint[$relativeMountPoint]; |
244 | - return array_map(function (ICacheEntry $result) use ($relativeMountPoint, $mount) { |
|
244 | + return array_map(function(ICacheEntry $result) use ($relativeMountPoint, $mount) { |
|
245 | 245 | return $this->cacheEntryToFileInfo($mount, $relativeMountPoint, $result); |
246 | 246 | }, $results); |
247 | 247 | }, array_values($resultsPerCache), array_keys($resultsPerCache))); |
248 | 248 | |
249 | 249 | // don't include this folder in the results |
250 | - $files = array_filter($files, function (FileInfo $file) { |
|
250 | + $files = array_filter($files, function(FileInfo $file) { |
|
251 | 251 | return $file->getPath() !== $this->getPath(); |
252 | 252 | }); |
253 | 253 | |
254 | 254 | // since results were returned per-cache, they are no longer fully sorted |
255 | 255 | $order = $query->getOrder(); |
256 | 256 | if ($order) { |
257 | - usort($files, function (FileInfo $a, FileInfo $b) use ($order) { |
|
257 | + usort($files, function(FileInfo $a, FileInfo $b) use ($order) { |
|
258 | 258 | foreach ($order as $orderField) { |
259 | 259 | $cmp = $orderField->sortFileInfo($a, $b); |
260 | 260 | if ($cmp !== 0) { |
@@ -265,16 +265,16 @@ discard block |
||
265 | 265 | }); |
266 | 266 | } |
267 | 267 | |
268 | - return array_map(function (FileInfo $file) { |
|
268 | + return array_map(function(FileInfo $file) { |
|
269 | 269 | return $this->createNode($file->getPath(), $file); |
270 | 270 | }, $files); |
271 | 271 | } |
272 | 272 | |
273 | 273 | private function cacheEntryToFileInfo(IMountPoint $mount, string $appendRoot, ICacheEntry $cacheEntry): FileInfo { |
274 | 274 | $cacheEntry['internalPath'] = $cacheEntry['path']; |
275 | - $cacheEntry['path'] = rtrim($appendRoot . $cacheEntry->getPath(), '/'); |
|
276 | - $subPath = $cacheEntry['path'] !== '' ? '/' . $cacheEntry['path'] : ''; |
|
277 | - return new \OC\Files\FileInfo($this->path . $subPath, $mount->getStorage(), $cacheEntry['internalPath'], $cacheEntry, $mount); |
|
275 | + $cacheEntry['path'] = rtrim($appendRoot.$cacheEntry->getPath(), '/'); |
|
276 | + $subPath = $cacheEntry['path'] !== '' ? '/'.$cacheEntry['path'] : ''; |
|
277 | + return new \OC\Files\FileInfo($this->path.$subPath, $mount->getStorage(), $cacheEntry['internalPath'], $cacheEntry, $mount); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | */ |
286 | 286 | public function searchByMime($mimetype) { |
287 | 287 | if (!str_contains($mimetype, '/')) { |
288 | - $query = $this->queryFromOperator(new SearchComparison(ISearchComparison::COMPARE_LIKE, 'mimetype', $mimetype . '/%')); |
|
288 | + $query = $this->queryFromOperator(new SearchComparison(ISearchComparison::COMPARE_LIKE, 'mimetype', $mimetype.'/%')); |
|
289 | 289 | } else { |
290 | 290 | $query = $this->queryFromOperator(new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'mimetype', $mimetype)); |
291 | 291 | } |
@@ -309,12 +309,12 @@ discard block |
||
309 | 309 | * @return \OC\Files\Node\Node[] |
310 | 310 | */ |
311 | 311 | public function getById($id) { |
312 | - return $this->root->getByIdInPath((int)$id, $this->getPath()); |
|
312 | + return $this->root->getByIdInPath((int) $id, $this->getPath()); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | protected function getAppDataDirectoryName(): string { |
316 | 316 | $instanceId = \OC::$server->getConfig()->getSystemValueString('instanceid'); |
317 | - return 'appdata_' . $instanceId; |
|
317 | + return 'appdata_'.$instanceId; |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | /** |
@@ -336,8 +336,8 @@ discard block |
||
336 | 336 | return []; |
337 | 337 | } |
338 | 338 | |
339 | - $absolutePath = '/' . ltrim($cacheEntry->getPath(), '/'); |
|
340 | - $currentPath = rtrim($this->path, '/') . '/'; |
|
339 | + $absolutePath = '/'.ltrim($cacheEntry->getPath(), '/'); |
|
340 | + $currentPath = rtrim($this->path, '/').'/'; |
|
341 | 341 | |
342 | 342 | if (!str_starts_with($absolutePath, $currentPath)) { |
343 | 343 | return []; |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | $nonExisting = new NonExistingFolder($this->root, $this->view, $this->path, $fileInfo); |
366 | 366 | $this->sendHooks(['postDelete'], [$nonExisting]); |
367 | 367 | } else { |
368 | - throw new NotPermittedException('No delete permission for path "' . $this->path . '"'); |
|
368 | + throw new NotPermittedException('No delete permission for path "'.$this->path.'"'); |
|
369 | 369 | } |
370 | 370 | } |
371 | 371 |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | } else { |
123 | 123 | // Update old classes to new namespace |
124 | 124 | if (str_contains($storage, 'OC_Filestorage_')) { |
125 | - $storage = '\OC\Files\Storage\\' . substr($storage, 15); |
|
125 | + $storage = '\OC\Files\Storage\\'.substr($storage, 15); |
|
126 | 126 | } |
127 | 127 | $this->class = $storage; |
128 | 128 | $this->arguments = $arguments; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | return; |
180 | 180 | } |
181 | 181 | } else { |
182 | - \OC::$server->get(LoggerInterface::class)->error('Storage backend ' . $this->class . ' not found', ['app' => 'core']); |
|
182 | + \OC::$server->get(LoggerInterface::class)->error('Storage backend '.$this->class.' not found', ['app' => 'core']); |
|
183 | 183 | $this->invalidStorage = true; |
184 | 184 | return; |
185 | 185 | } |
@@ -232,13 +232,13 @@ discard block |
||
232 | 232 | */ |
233 | 233 | public function getInternalPath($path) { |
234 | 234 | $path = Filesystem::normalizePath($path, true, false, true); |
235 | - if ($this->mountPoint === $path or $this->mountPoint . '/' === $path) { |
|
235 | + if ($this->mountPoint === $path or $this->mountPoint.'/' === $path) { |
|
236 | 236 | $internalPath = ''; |
237 | 237 | } else { |
238 | 238 | $internalPath = substr($path, strlen($this->mountPoint)); |
239 | 239 | } |
240 | 240 | // substr returns false instead of an empty string, we always want a string |
241 | - return (string)$internalPath; |
|
241 | + return (string) $internalPath; |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -296,7 +296,7 @@ discard block |
||
296 | 296 | if ($storage === null) { |
297 | 297 | $this->rootId = -1; |
298 | 298 | } else { |
299 | - $this->rootId = (int)$storage->getCache()->getId(''); |
|
299 | + $this->rootId = (int) $storage->getCache()->getId(''); |
|
300 | 300 | } |
301 | 301 | } |
302 | 302 | return $this->rootId; |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $request = $this->prepareRequest($request, $credentials); |
66 | 66 | $stringToSign = $this->createCanonicalizedString($request); |
67 | 67 | $auth = 'AWS ' |
68 | - . $credentials->getAccessKeyId() . ':' |
|
68 | + . $credentials->getAccessKeyId().':' |
|
69 | 69 | . $this->signString($stringToSign, $credentials); |
70 | 70 | |
71 | 71 | return $request->withHeader('Authorization', $auth); |
@@ -150,11 +150,11 @@ discard block |
||
150 | 150 | RequestInterface $request, |
151 | 151 | $expires = null |
152 | 152 | ) { |
153 | - $buffer = $request->getMethod() . "\n"; |
|
153 | + $buffer = $request->getMethod()."\n"; |
|
154 | 154 | |
155 | 155 | // Add the interesting headers |
156 | 156 | foreach ($this->signableHeaders as $header) { |
157 | - $buffer .= $request->getHeaderLine($header) . "\n"; |
|
157 | + $buffer .= $request->getHeaderLine($header)."\n"; |
|
158 | 158 | } |
159 | 159 | |
160 | 160 | $date = $expires ?: $request->getHeaderLine('date'); |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | if (str_starts_with($name, 'x-amz-')) { |
173 | 173 | $value = implode(',', $header); |
174 | 174 | if (strlen($value) > 0) { |
175 | - $headers[$name] = $name . ':' . $value; |
|
175 | + $headers[$name] = $name.':'.$value; |
|
176 | 176 | } |
177 | 177 | } |
178 | 178 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | |
184 | 184 | ksort($headers); |
185 | 185 | |
186 | - return implode("\n", $headers) . "\n"; |
|
186 | + return implode("\n", $headers)."\n"; |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | private function createCanonicalizedResource(RequestInterface $request) { |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | if ($data['bucket']) { |
194 | 194 | $buffer .= $data['bucket']; |
195 | 195 | if (!empty($data['key']) || !$data['path_style']) { |
196 | - $buffer .= '/' . $data['key']; |
|
196 | + $buffer .= '/'.$data['key']; |
|
197 | 197 | } |
198 | 198 | } |
199 | 199 |