@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function shouldJoinTags(ISearchOperator $operator) { |
78 | 78 | if ($operator instanceof ISearchBinaryOperator) { |
79 | - return array_reduce($operator->getArguments(), function ($shouldJoin, ISearchOperator $operator) { |
|
79 | + return array_reduce($operator->getArguments(), function($shouldJoin, ISearchOperator $operator) { |
|
80 | 80 | return $shouldJoin || $this->shouldJoinTags($operator); |
81 | 81 | }, false); |
82 | 82 | } elseif ($operator instanceof ISearchComparison) { |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param ISearchOperator[] $operators |
91 | 91 | */ |
92 | 92 | public function searchOperatorArrayToDBExprArray(IQueryBuilder $builder, array $operators) { |
93 | - return array_filter(array_map(function ($operator) use ($builder) { |
|
93 | + return array_filter(array_map(function($operator) use ($builder) { |
|
94 | 94 | return $this->searchOperatorToDBExpr($builder, $operator); |
95 | 95 | }, $operators)); |
96 | 96 | } |
@@ -117,12 +117,12 @@ discard block |
||
117 | 117 | case ISearchBinaryOperator::OPERATOR_OR: |
118 | 118 | return call_user_func_array([$expr, 'orX'], $this->searchOperatorArrayToDBExprArray($builder, $operator->getArguments())); |
119 | 119 | default: |
120 | - throw new \InvalidArgumentException('Invalid operator type: ' . $operator->getType()); |
|
120 | + throw new \InvalidArgumentException('Invalid operator type: '.$operator->getType()); |
|
121 | 121 | } |
122 | 122 | } elseif ($operator instanceof ISearchComparison) { |
123 | 123 | return $this->searchComparisonToDBExpr($builder, $operator, self::$searchOperatorMap); |
124 | 124 | } else { |
125 | - throw new \InvalidArgumentException('Invalid operator type: ' . get_class($operator)); |
|
125 | + throw new \InvalidArgumentException('Invalid operator type: '.get_class($operator)); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | $queryOperator = $operatorMap[$type]; |
135 | 135 | return $builder->expr()->$queryOperator($field, $this->getParameterForValue($builder, $value)); |
136 | 136 | } else { |
137 | - throw new \InvalidArgumentException('Invalid operator type: ' . $comparison->getType()); |
|
137 | + throw new \InvalidArgumentException('Invalid operator type: '.$comparison->getType()); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
@@ -143,20 +143,20 @@ discard block |
||
143 | 143 | $value = $operator->getValue(); |
144 | 144 | $type = $operator->getType(); |
145 | 145 | if ($field === 'mimetype') { |
146 | - $value = (string)$value; |
|
146 | + $value = (string) $value; |
|
147 | 147 | if ($operator->getType() === ISearchComparison::COMPARE_EQUAL) { |
148 | - $value = (int)$this->mimetypeLoader->getId($value); |
|
148 | + $value = (int) $this->mimetypeLoader->getId($value); |
|
149 | 149 | } elseif ($operator->getType() === ISearchComparison::COMPARE_LIKE) { |
150 | 150 | // transform "mimetype='foo/%'" to "mimepart='foo'" |
151 | 151 | if (preg_match('|(.+)/%|', $value, $matches)) { |
152 | 152 | $field = 'mimepart'; |
153 | - $value = (int)$this->mimetypeLoader->getId($matches[1]); |
|
153 | + $value = (int) $this->mimetypeLoader->getId($matches[1]); |
|
154 | 154 | $type = ISearchComparison::COMPARE_EQUAL; |
155 | 155 | } elseif (str_contains($value, '%')) { |
156 | - throw new \InvalidArgumentException('Unsupported query value for mimetype: ' . $value . ', only values in the format "mime/type" or "mime/%" are supported'); |
|
156 | + throw new \InvalidArgumentException('Unsupported query value for mimetype: '.$value.', only values in the format "mime/type" or "mime/%" are supported'); |
|
157 | 157 | } else { |
158 | 158 | $field = 'mimetype'; |
159 | - $value = (int)$this->mimetypeLoader->getId($value); |
|
159 | + $value = (int) $this->mimetypeLoader->getId($value); |
|
160 | 160 | $type = ISearchComparison::COMPARE_EQUAL; |
161 | 161 | } |
162 | 162 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | $field = 'file.fileid'; |
174 | 174 | } elseif ($field === 'path' && $type === ISearchComparison::COMPARE_EQUAL && $operator->getQueryHint(ISearchComparison::HINT_PATH_EQ_HASH, true)) { |
175 | 175 | $field = 'path_hash'; |
176 | - $value = md5((string)$value); |
|
176 | + $value = md5((string) $value); |
|
177 | 177 | } |
178 | 178 | return [$field, $value, $type]; |
179 | 179 | } |
@@ -205,14 +205,14 @@ discard block |
||
205 | 205 | ]; |
206 | 206 | |
207 | 207 | if (!isset($types[$operator->getField()])) { |
208 | - throw new \InvalidArgumentException('Unsupported comparison field ' . $operator->getField()); |
|
208 | + throw new \InvalidArgumentException('Unsupported comparison field '.$operator->getField()); |
|
209 | 209 | } |
210 | 210 | $type = $types[$operator->getField()]; |
211 | 211 | if (gettype($operator->getValue()) !== $type) { |
212 | - throw new \InvalidArgumentException('Invalid type for field ' . $operator->getField()); |
|
212 | + throw new \InvalidArgumentException('Invalid type for field '.$operator->getField()); |
|
213 | 213 | } |
214 | 214 | if (!in_array($operator->getType(), $comparisons[$operator->getField()])) { |
215 | - throw new \InvalidArgumentException('Unsupported comparison for field ' . $operator->getField() . ': ' . $operator->getType()); |
|
215 | + throw new \InvalidArgumentException('Unsupported comparison for field '.$operator->getField().': '.$operator->getType()); |
|
216 | 216 | } |
217 | 217 | } |
218 | 218 |
@@ -188,29 +188,29 @@ discard block |
||
188 | 188 | */ |
189 | 189 | public static function cacheEntryFromData($data, IMimeTypeLoader $mimetypeLoader) { |
190 | 190 | //fix types |
191 | - $data['name'] = (string)$data['name']; |
|
192 | - $data['path'] = (string)$data['path']; |
|
193 | - $data['fileid'] = (int)$data['fileid']; |
|
194 | - $data['parent'] = (int)$data['parent']; |
|
191 | + $data['name'] = (string) $data['name']; |
|
192 | + $data['path'] = (string) $data['path']; |
|
193 | + $data['fileid'] = (int) $data['fileid']; |
|
194 | + $data['parent'] = (int) $data['parent']; |
|
195 | 195 | $data['size'] = Util::numericToNumber($data['size']); |
196 | 196 | $data['unencrypted_size'] = Util::numericToNumber($data['unencrypted_size'] ?? 0); |
197 | - $data['mtime'] = (int)$data['mtime']; |
|
198 | - $data['storage_mtime'] = (int)$data['storage_mtime']; |
|
199 | - $data['encryptedVersion'] = (int)$data['encrypted']; |
|
200 | - $data['encrypted'] = (bool)$data['encrypted']; |
|
197 | + $data['mtime'] = (int) $data['mtime']; |
|
198 | + $data['storage_mtime'] = (int) $data['storage_mtime']; |
|
199 | + $data['encryptedVersion'] = (int) $data['encrypted']; |
|
200 | + $data['encrypted'] = (bool) $data['encrypted']; |
|
201 | 201 | $data['storage_id'] = $data['storage']; |
202 | - $data['storage'] = (int)$data['storage']; |
|
202 | + $data['storage'] = (int) $data['storage']; |
|
203 | 203 | $data['mimetype'] = $mimetypeLoader->getMimetypeById($data['mimetype']); |
204 | 204 | $data['mimepart'] = $mimetypeLoader->getMimetypeById($data['mimepart']); |
205 | 205 | if ($data['storage_mtime'] == 0) { |
206 | 206 | $data['storage_mtime'] = $data['mtime']; |
207 | 207 | } |
208 | - $data['permissions'] = (int)$data['permissions']; |
|
208 | + $data['permissions'] = (int) $data['permissions']; |
|
209 | 209 | if (isset($data['creation_time'])) { |
210 | - $data['creation_time'] = (int)$data['creation_time']; |
|
210 | + $data['creation_time'] = (int) $data['creation_time']; |
|
211 | 211 | } |
212 | 212 | if (isset($data['upload_time'])) { |
213 | - $data['upload_time'] = (int)$data['upload_time']; |
|
213 | + $data['upload_time'] = (int) $data['upload_time']; |
|
214 | 214 | } |
215 | 215 | return new CacheEntry($data); |
216 | 216 | } |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | $files = $result->fetchAll(); |
244 | 244 | $result->closeCursor(); |
245 | 245 | |
246 | - return array_map(function (array $data) { |
|
246 | + return array_map(function(array $data) { |
|
247 | 247 | return self::cacheEntryFromData($data, $this->mimetypeLoader); |
248 | 248 | }, $files); |
249 | 249 | } |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | |
373 | 373 | $query->update('filecache') |
374 | 374 | ->whereFileId($id) |
375 | - ->andWhere($query->expr()->orX(...array_map(function ($key, $value) use ($query) { |
|
375 | + ->andWhere($query->expr()->orX(...array_map(function($key, $value) use ($query) { |
|
376 | 376 | return $query->expr()->orX( |
377 | 377 | $query->expr()->neq($key, $query->createNamedParameter($value)), |
378 | 378 | $query->expr()->isNull($key) |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | $query = $this->getQueryBuilder(); |
402 | 402 | $query->update('filecache_extended') |
403 | 403 | ->whereFileId($id) |
404 | - ->andWhere($query->expr()->orX(...array_map(function ($key, $value) use ($query) { |
|
404 | + ->andWhere($query->expr()->orX(...array_map(function($key, $value) use ($query) { |
|
405 | 405 | return $query->expr()->orX( |
406 | 406 | $query->expr()->neq($key, $query->createNamedParameter($value)), |
407 | 407 | $query->expr()->isNull($key) |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | $id = $result->fetchOne(); |
499 | 499 | $result->closeCursor(); |
500 | 500 | |
501 | - return $id === false ? -1 : (int)$id; |
|
501 | + return $id === false ? -1 : (int) $id; |
|
502 | 502 | } |
503 | 503 | |
504 | 504 | /** |
@@ -512,7 +512,7 @@ discard block |
||
512 | 512 | return -1; |
513 | 513 | } else { |
514 | 514 | $parent = $this->getParentPath($file); |
515 | - return (int)$this->getId($parent); |
|
515 | + return (int) $this->getId($parent); |
|
516 | 516 | } |
517 | 517 | } |
518 | 518 | |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | */ |
572 | 572 | private function getSubFolders(ICacheEntry $entry) { |
573 | 573 | $children = $this->getFolderContentsById($entry->getId()); |
574 | - return array_filter($children, function ($child) { |
|
574 | + return array_filter($children, function($child) { |
|
575 | 575 | return $child->getMimeType() == FileInfo::MIMETYPE_FOLDER; |
576 | 576 | }); |
577 | 577 | } |
@@ -592,10 +592,10 @@ discard block |
||
592 | 592 | // and collecting all folder ids to later use to delete the filecache entries |
593 | 593 | while ($entryId = array_pop($queue)) { |
594 | 594 | $children = $this->getFolderContentsById($entryId); |
595 | - $childIds = array_map(function (ICacheEntry $cacheEntry) { |
|
595 | + $childIds = array_map(function(ICacheEntry $cacheEntry) { |
|
596 | 596 | return $cacheEntry->getId(); |
597 | 597 | }, $children); |
598 | - $childPaths = array_map(function (ICacheEntry $cacheEntry) { |
|
598 | + $childPaths = array_map(function(ICacheEntry $cacheEntry) { |
|
599 | 599 | return $cacheEntry->getPath(); |
600 | 600 | }, $children); |
601 | 601 | |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | } |
613 | 613 | |
614 | 614 | /** @var ICacheEntry[] $childFolders */ |
615 | - $childFolders = array_filter($children, function ($child) { |
|
615 | + $childFolders = array_filter($children, function($child) { |
|
616 | 616 | return $child->getMimeType() == FileInfo::MIMETYPE_FOLDER; |
617 | 617 | }); |
618 | 618 | foreach ($childFolders as $folder) { |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | |
683 | 683 | $sourceData = $sourceCache->get($sourcePath); |
684 | 684 | if ($sourceData === false) { |
685 | - throw new \Exception('Invalid source storage path: ' . $sourcePath); |
|
685 | + throw new \Exception('Invalid source storage path: '.$sourcePath); |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | $sourceId = $sourceData['fileid']; |
@@ -692,10 +692,10 @@ discard block |
||
692 | 692 | [$targetStorageId, $targetPath] = $this->getMoveInfo($targetPath); |
693 | 693 | |
694 | 694 | if (is_null($sourceStorageId) || $sourceStorageId === false) { |
695 | - throw new \Exception('Invalid source storage id: ' . $sourceStorageId); |
|
695 | + throw new \Exception('Invalid source storage id: '.$sourceStorageId); |
|
696 | 696 | } |
697 | 697 | if (is_null($targetStorageId) || $targetStorageId === false) { |
698 | - throw new \Exception('Invalid target storage id: ' . $targetStorageId); |
|
698 | + throw new \Exception('Invalid target storage id: '.$targetStorageId); |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | $this->connection->beginTransaction(); |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | ->set('path_hash', $fun->md5($newPathFunction)) |
715 | 715 | ->set('path', $newPathFunction) |
716 | 716 | ->where($query->expr()->eq('storage', $query->createNamedParameter($sourceStorageId, IQueryBuilder::PARAM_INT))) |
717 | - ->andWhere($query->expr()->like('path', $query->createNamedParameter($this->connection->escapeLikeParameter($sourcePath) . '/%'))); |
|
717 | + ->andWhere($query->expr()->like('path', $query->createNamedParameter($this->connection->escapeLikeParameter($sourcePath).'/%'))); |
|
718 | 718 | |
719 | 719 | // when moving from an encrypted storage to a non-encrypted storage remove the `encrypted` mark |
720 | 720 | if ($sourceCache->hasEncryptionWrapper() && !$this->hasEncryptionWrapper()) { |
@@ -804,7 +804,7 @@ discard block |
||
804 | 804 | $result->closeCursor(); |
805 | 805 | |
806 | 806 | if ($size !== false) { |
807 | - if ((int)$size === -1) { |
|
807 | + if ((int) $size === -1) { |
|
808 | 808 | return self::SHALLOW; |
809 | 809 | } else { |
810 | 810 | return self::COMPLETE; |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | */ |
839 | 839 | public function searchByMime($mimetype) { |
840 | 840 | if (!str_contains($mimetype, '/')) { |
841 | - $operator = new SearchComparison(ISearchComparison::COMPARE_LIKE, 'mimetype', $mimetype . '/%'); |
|
841 | + $operator = new SearchComparison(ISearchComparison::COMPARE_LIKE, 'mimetype', $mimetype.'/%'); |
|
842 | 842 | } else { |
843 | 843 | $operator = new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'mimetype', $mimetype); |
844 | 844 | } |
@@ -888,7 +888,7 @@ discard block |
||
888 | 888 | ->andWhere($query->expr()->lt('size', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT))); |
889 | 889 | |
890 | 890 | $result = $query->execute(); |
891 | - $size = (int)$result->fetchOne(); |
|
891 | + $size = (int) $result->fetchOne(); |
|
892 | 892 | $result->closeCursor(); |
893 | 893 | |
894 | 894 | return $size; |
@@ -937,13 +937,13 @@ discard block |
||
937 | 937 | $result->closeCursor(); |
938 | 938 | |
939 | 939 | if ($rows) { |
940 | - $sizes = array_map(function (array $row) { |
|
940 | + $sizes = array_map(function(array $row) { |
|
941 | 941 | return Util::numericToNumber($row['size']); |
942 | 942 | }, $rows); |
943 | - $unencryptedOnlySizes = array_map(function (array $row) { |
|
943 | + $unencryptedOnlySizes = array_map(function(array $row) { |
|
944 | 944 | return Util::numericToNumber($row['unencrypted_size']); |
945 | 945 | }, $rows); |
946 | - $unencryptedSizes = array_map(function (array $row) { |
|
946 | + $unencryptedSizes = array_map(function(array $row) { |
|
947 | 947 | return Util::numericToNumber(($row['unencrypted_size'] > 0) ? $row['unencrypted_size'] : $row['size']); |
948 | 948 | }, $rows); |
949 | 949 | |
@@ -1010,8 +1010,8 @@ discard block |
||
1010 | 1010 | $files = $result->fetchAll(\PDO::FETCH_COLUMN); |
1011 | 1011 | $result->closeCursor(); |
1012 | 1012 | |
1013 | - return array_map(function ($id) { |
|
1014 | - return (int)$id; |
|
1013 | + return array_map(function($id) { |
|
1014 | + return (int) $id; |
|
1015 | 1015 | }, $files); |
1016 | 1016 | } |
1017 | 1017 | |
@@ -1042,7 +1042,7 @@ discard block |
||
1042 | 1042 | } |
1043 | 1043 | |
1044 | 1044 | // Make sure Oracle does not continue with null for empty strings |
1045 | - return (string)$path; |
|
1045 | + return (string) $path; |
|
1046 | 1046 | } |
1047 | 1047 | |
1048 | 1048 | /** |
@@ -1066,7 +1066,7 @@ discard block |
||
1066 | 1066 | return null; |
1067 | 1067 | } |
1068 | 1068 | |
1069 | - return (string)$path; |
|
1069 | + return (string) $path; |
|
1070 | 1070 | } |
1071 | 1071 | |
1072 | 1072 | /** |
@@ -1133,12 +1133,12 @@ discard block |
||
1133 | 1133 | |
1134 | 1134 | $fileId = $this->put($targetPath, $data); |
1135 | 1135 | if ($fileId <= 0) { |
1136 | - throw new \RuntimeException("Failed to copy to " . $targetPath . " from cache with source data " . json_encode($data) . " "); |
|
1136 | + throw new \RuntimeException("Failed to copy to ".$targetPath." from cache with source data ".json_encode($data)." "); |
|
1137 | 1137 | } |
1138 | 1138 | if ($sourceEntry->getMimeType() === ICacheEntry::DIRECTORY_MIMETYPE) { |
1139 | 1139 | $folderContent = $sourceCache->getFolderContentsById($sourceEntry->getId()); |
1140 | 1140 | foreach ($folderContent as $subEntry) { |
1141 | - $subTargetPath = $targetPath . '/' . $subEntry->getName(); |
|
1141 | + $subTargetPath = $targetPath.'/'.$subEntry->getName(); |
|
1142 | 1142 | $this->copyFromCache($sourceCache, $subEntry, $subTargetPath); |
1143 | 1143 | } |
1144 | 1144 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | } |
59 | 59 | |
60 | 60 | public function getUnjailedPath($path) { |
61 | - return trim(Filesystem::normalizePath($this->rootPath . '/' . $path), '/'); |
|
61 | + return trim(Filesystem::normalizePath($this->rootPath.'/'.$path), '/'); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | |
72 | 72 | public function getJailedPath($path) { |
73 | - $root = rtrim($this->rootPath, '/') . '/'; |
|
73 | + $root = rtrim($this->rootPath, '/').'/'; |
|
74 | 74 | |
75 | 75 | if ($path !== $this->rootPath && !str_starts_with($path, $root)) { |
76 | 76 | return null; |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | * see https://www.php.net/manual/en/function.filesize.php |
160 | 160 | * The result for filesize when called on a folder is required to be 0 |
161 | 161 | */ |
162 | - public function filesize($path): false|int|float { |
|
162 | + public function filesize($path): false | int | float { |
|
163 | 163 | return $this->getWrapperStorage()->filesize($this->getUnjailedPath($path)); |
164 | 164 | } |
165 | 165 |
@@ -124,9 +124,9 @@ discard block |
||
124 | 124 | $path = '/'; |
125 | 125 | } |
126 | 126 | if ($path[0] !== '/') { |
127 | - $path = '/' . $path; |
|
127 | + $path = '/'.$path; |
|
128 | 128 | } |
129 | - return $this->fakeRoot . $path; |
|
129 | + return $this->fakeRoot.$path; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | public function chroot($fakeRoot): void { |
138 | 138 | if (!$fakeRoot == '') { |
139 | 139 | if ($fakeRoot[0] !== '/') { |
140 | - $fakeRoot = '/' . $fakeRoot; |
|
140 | + $fakeRoot = '/'.$fakeRoot; |
|
141 | 141 | } |
142 | 142 | } |
143 | 143 | $this->fakeRoot = $fakeRoot; |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | } |
167 | 167 | |
168 | 168 | // missing slashes can cause wrong matches! |
169 | - $root = rtrim($this->fakeRoot, '/') . '/'; |
|
169 | + $root = rtrim($this->fakeRoot, '/').'/'; |
|
170 | 170 | |
171 | 171 | if (!str_starts_with($path, $root)) { |
172 | 172 | return null; |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | * |
224 | 224 | * @param string $path |
225 | 225 | */ |
226 | - public function getLocalFile($path): string|false { |
|
226 | + public function getLocalFile($path): string | false { |
|
227 | 227 | $parent = substr($path, 0, strrpos($path, '/') ?: 0); |
228 | 228 | $path = $this->getAbsolutePath($path); |
229 | 229 | [$storage, $internalPath] = Filesystem::resolvePath($path); |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | if ($mount instanceof MoveableMount) { |
254 | 254 | // cut of /user/files to get the relative path to data/user/files |
255 | 255 | $pathParts = explode('/', $path, 4); |
256 | - $relPath = '/' . $pathParts[3]; |
|
256 | + $relPath = '/'.$pathParts[3]; |
|
257 | 257 | $this->lockFile($relPath, ILockingProvider::LOCK_SHARED, true); |
258 | 258 | \OC_Hook::emit( |
259 | 259 | Filesystem::CLASSNAME, "umount", |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | } |
683 | 683 | $postFix = (substr($path, -1) === '/') ? '/' : ''; |
684 | 684 | $absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path)); |
685 | - $mount = Filesystem::getMountManager()->find($absolutePath . $postFix); |
|
685 | + $mount = Filesystem::getMountManager()->find($absolutePath.$postFix); |
|
686 | 686 | if ($mount->getInternalPath($absolutePath) === '') { |
687 | 687 | return $this->removeMount($mount, $absolutePath); |
688 | 688 | } |
@@ -959,7 +959,7 @@ discard block |
||
959 | 959 | $hooks[] = 'write'; |
960 | 960 | break; |
961 | 961 | default: |
962 | - $this->logger->error('invalid mode (' . $mode . ') for ' . $path, ['app' => 'core']); |
|
962 | + $this->logger->error('invalid mode ('.$mode.') for '.$path, ['app' => 'core']); |
|
963 | 963 | } |
964 | 964 | |
965 | 965 | if ($mode !== 'r' && $mode !== 'w') { |
@@ -983,7 +983,7 @@ discard block |
||
983 | 983 | * @param string $path |
984 | 984 | * @throws InvalidPathException |
985 | 985 | */ |
986 | - public function toTmpFile($path): string|false { |
|
986 | + public function toTmpFile($path): string | false { |
|
987 | 987 | $this->assertPathLength($path); |
988 | 988 | if (Filesystem::isValidPath($path)) { |
989 | 989 | $source = $this->fopen($path, 'r'); |
@@ -1058,7 +1058,7 @@ discard block |
||
1058 | 1058 | * @param string $path |
1059 | 1059 | * @param bool $raw |
1060 | 1060 | */ |
1061 | - public function hash($type, $path, $raw = false): string|bool { |
|
1061 | + public function hash($type, $path, $raw = false): string | bool { |
|
1062 | 1062 | $postFix = (substr($path, -1) === '/') ? '/' : ''; |
1063 | 1063 | $absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path)); |
1064 | 1064 | if (Filesystem::isValidPath($path)) { |
@@ -1074,7 +1074,7 @@ discard block |
||
1074 | 1074 | ); |
1075 | 1075 | } |
1076 | 1076 | /** @var Storage|null $storage */ |
1077 | - [$storage, $internalPath] = Filesystem::resolvePath($absolutePath . $postFix); |
|
1077 | + [$storage, $internalPath] = Filesystem::resolvePath($absolutePath.$postFix); |
|
1078 | 1078 | if ($storage) { |
1079 | 1079 | return $storage->hash($type, $internalPath, $raw); |
1080 | 1080 | } |
@@ -1124,7 +1124,7 @@ discard block |
||
1124 | 1124 | } |
1125 | 1125 | |
1126 | 1126 | $run = $this->runHooks($hooks, $path); |
1127 | - [$storage, $internalPath] = Filesystem::resolvePath($absolutePath . $postFix); |
|
1127 | + [$storage, $internalPath] = Filesystem::resolvePath($absolutePath.$postFix); |
|
1128 | 1128 | if ($run && $storage) { |
1129 | 1129 | /** @var Storage $storage */ |
1130 | 1130 | if (in_array('write', $hooks) || in_array('delete', $hooks)) { |
@@ -1170,7 +1170,7 @@ discard block |
||
1170 | 1170 | $unlockLater = true; |
1171 | 1171 | // make sure our unlocking callback will still be called if connection is aborted |
1172 | 1172 | ignore_user_abort(true); |
1173 | - $result = CallbackWrapper::wrap($result, null, null, function () use ($hooks, $path) { |
|
1173 | + $result = CallbackWrapper::wrap($result, null, null, function() use ($hooks, $path) { |
|
1174 | 1174 | if (in_array('write', $hooks)) { |
1175 | 1175 | $this->unlockFile($path, ILockingProvider::LOCK_EXCLUSIVE); |
1176 | 1176 | } elseif (in_array('read', $hooks)) { |
@@ -1232,7 +1232,7 @@ discard block |
||
1232 | 1232 | return true; |
1233 | 1233 | } |
1234 | 1234 | |
1235 | - return (strlen($fullPath) > strlen($defaultRoot)) && (substr($fullPath, 0, strlen($defaultRoot) + 1) === $defaultRoot . '/'); |
|
1235 | + return (strlen($fullPath) > strlen($defaultRoot)) && (substr($fullPath, 0, strlen($defaultRoot) + 1) === $defaultRoot.'/'); |
|
1236 | 1236 | } |
1237 | 1237 | |
1238 | 1238 | /** |
@@ -1251,7 +1251,7 @@ discard block |
||
1251 | 1251 | if ($hook != 'read') { |
1252 | 1252 | \OC_Hook::emit( |
1253 | 1253 | Filesystem::CLASSNAME, |
1254 | - $prefix . $hook, |
|
1254 | + $prefix.$hook, |
|
1255 | 1255 | [ |
1256 | 1256 | Filesystem::signal_param_run => &$run, |
1257 | 1257 | Filesystem::signal_param_path => $path |
@@ -1260,7 +1260,7 @@ discard block |
||
1260 | 1260 | } elseif (!$post) { |
1261 | 1261 | \OC_Hook::emit( |
1262 | 1262 | Filesystem::CLASSNAME, |
1263 | - $prefix . $hook, |
|
1263 | + $prefix.$hook, |
|
1264 | 1264 | [ |
1265 | 1265 | Filesystem::signal_param_path => $path |
1266 | 1266 | ] |
@@ -1347,7 +1347,7 @@ discard block |
||
1347 | 1347 | return $this->getPartFileInfo($path); |
1348 | 1348 | } |
1349 | 1349 | $relativePath = $path; |
1350 | - $path = Filesystem::normalizePath($this->fakeRoot . '/' . $path); |
|
1350 | + $path = Filesystem::normalizePath($this->fakeRoot.'/'.$path); |
|
1351 | 1351 | |
1352 | 1352 | $mount = Filesystem::getMountManager()->find($path); |
1353 | 1353 | $storage = $mount->getStorage(); |
@@ -1380,7 +1380,7 @@ discard block |
||
1380 | 1380 | |
1381 | 1381 | return $info; |
1382 | 1382 | } else { |
1383 | - $this->logger->warning('Storage not valid for mountpoint: ' . $mount->getMountPoint(), ['app' => 'core']); |
|
1383 | + $this->logger->warning('Storage not valid for mountpoint: '.$mount->getMountPoint(), ['app' => 'core']); |
|
1384 | 1384 | } |
1385 | 1385 | |
1386 | 1386 | return false; |
@@ -1391,7 +1391,7 @@ discard block |
||
1391 | 1391 | */ |
1392 | 1392 | public function addSubMounts(FileInfo $info, $extOnly = false): void { |
1393 | 1393 | $mounts = Filesystem::getMountManager()->findIn($info->getPath()); |
1394 | - $info->setSubMounts(array_filter($mounts, function (IMountPoint $mount) use ($extOnly) { |
|
1394 | + $info->setSubMounts(array_filter($mounts, function(IMountPoint $mount) use ($extOnly) { |
|
1395 | 1395 | $subStorage = $mount->getStorage(); |
1396 | 1396 | return !($extOnly && $subStorage instanceof \OCA\Files_Sharing\SharedStorage); |
1397 | 1397 | })); |
@@ -1440,18 +1440,18 @@ discard block |
||
1440 | 1440 | |
1441 | 1441 | $sharingDisabled = \OCP\Util::isSharingDisabledForUser(); |
1442 | 1442 | |
1443 | - $fileNames = array_map(function (ICacheEntry $content) { |
|
1443 | + $fileNames = array_map(function(ICacheEntry $content) { |
|
1444 | 1444 | return $content->getName(); |
1445 | 1445 | }, $contents); |
1446 | 1446 | /** |
1447 | 1447 | * @var \OC\Files\FileInfo[] $fileInfos |
1448 | 1448 | */ |
1449 | - $fileInfos = array_map(function (ICacheEntry $content) use ($path, $storage, $mount, $sharingDisabled) { |
|
1449 | + $fileInfos = array_map(function(ICacheEntry $content) use ($path, $storage, $mount, $sharingDisabled) { |
|
1450 | 1450 | if ($sharingDisabled) { |
1451 | 1451 | $content['permissions'] = $content['permissions'] & ~\OCP\Constants::PERMISSION_SHARE; |
1452 | 1452 | } |
1453 | 1453 | $owner = $this->getUserObjectForOwner($storage->getOwner($content['path'])); |
1454 | - return new FileInfo($path . '/' . $content['name'], $storage, $content['path'], $content, $mount, $owner); |
|
1454 | + return new FileInfo($path.'/'.$content['name'], $storage, $content['path'], $content, $mount, $owner); |
|
1455 | 1455 | }, $contents); |
1456 | 1456 | $files = array_combine($fileNames, $fileInfos); |
1457 | 1457 | |
@@ -1475,7 +1475,7 @@ discard block |
||
1475 | 1475 | continue; |
1476 | 1476 | } catch (\Exception $e) { |
1477 | 1477 | // sometimes when the storage is not available it can be any exception |
1478 | - $this->logger->error('Exception while scanning storage "' . $subStorage->getId() . '"', [ |
|
1478 | + $this->logger->error('Exception while scanning storage "'.$subStorage->getId().'"', [ |
|
1479 | 1479 | 'exception' => $e, |
1480 | 1480 | 'app' => 'core', |
1481 | 1481 | ]); |
@@ -1504,7 +1504,7 @@ discard block |
||
1504 | 1504 | $rootEntry['permissions'] = $permissions & (\OCP\Constants::PERMISSION_ALL - (\OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE)); |
1505 | 1505 | } |
1506 | 1506 | |
1507 | - $rootEntry['path'] = substr(Filesystem::normalizePath($path . '/' . $rootEntry['name']), strlen($user) + 2); // full path without /$user/ |
|
1507 | + $rootEntry['path'] = substr(Filesystem::normalizePath($path.'/'.$rootEntry['name']), strlen($user) + 2); // full path without /$user/ |
|
1508 | 1508 | |
1509 | 1509 | // if sharing was disabled for the user we remove the share permissions |
1510 | 1510 | if (\OCP\Util::isSharingDisabledForUser()) { |
@@ -1512,14 +1512,14 @@ discard block |
||
1512 | 1512 | } |
1513 | 1513 | |
1514 | 1514 | $owner = $this->getUserObjectForOwner($subStorage->getOwner('')); |
1515 | - $files[$rootEntry->getName()] = new FileInfo($path . '/' . $rootEntry['name'], $subStorage, '', $rootEntry, $mount, $owner); |
|
1515 | + $files[$rootEntry->getName()] = new FileInfo($path.'/'.$rootEntry['name'], $subStorage, '', $rootEntry, $mount, $owner); |
|
1516 | 1516 | } |
1517 | 1517 | } |
1518 | 1518 | } |
1519 | 1519 | } |
1520 | 1520 | |
1521 | 1521 | if ($mimetype_filter) { |
1522 | - $files = array_filter($files, function (FileInfo $file) use ($mimetype_filter) { |
|
1522 | + $files = array_filter($files, function(FileInfo $file) use ($mimetype_filter) { |
|
1523 | 1523 | if (strpos($mimetype_filter, '/')) { |
1524 | 1524 | return $file->getMimetype() === $mimetype_filter; |
1525 | 1525 | } else { |
@@ -1545,7 +1545,7 @@ discard block |
||
1545 | 1545 | if ($data instanceof FileInfo) { |
1546 | 1546 | $data = $data->getData(); |
1547 | 1547 | } |
1548 | - $path = Filesystem::normalizePath($this->fakeRoot . '/' . $path); |
|
1548 | + $path = Filesystem::normalizePath($this->fakeRoot.'/'.$path); |
|
1549 | 1549 | /** |
1550 | 1550 | * @var Storage $storage |
1551 | 1551 | * @var string $internalPath |
@@ -1572,7 +1572,7 @@ discard block |
||
1572 | 1572 | * @return FileInfo[] |
1573 | 1573 | */ |
1574 | 1574 | public function search($query) { |
1575 | - return $this->searchCommon('search', ['%' . $query . '%']); |
|
1575 | + return $this->searchCommon('search', ['%'.$query.'%']); |
|
1576 | 1576 | } |
1577 | 1577 | |
1578 | 1578 | /** |
@@ -1624,10 +1624,10 @@ discard block |
||
1624 | 1624 | |
1625 | 1625 | $results = call_user_func_array([$cache, $method], $args); |
1626 | 1626 | foreach ($results as $result) { |
1627 | - if (substr($mountPoint . $result['path'], 0, $rootLength + 1) === $this->fakeRoot . '/') { |
|
1627 | + if (substr($mountPoint.$result['path'], 0, $rootLength + 1) === $this->fakeRoot.'/') { |
|
1628 | 1628 | $internalPath = $result['path']; |
1629 | - $path = $mountPoint . $result['path']; |
|
1630 | - $result['path'] = substr($mountPoint . $result['path'], $rootLength); |
|
1629 | + $path = $mountPoint.$result['path']; |
|
1630 | + $result['path'] = substr($mountPoint.$result['path'], $rootLength); |
|
1631 | 1631 | $owner = $userManager->get($storage->getOwner($internalPath)); |
1632 | 1632 | $files[] = new FileInfo($path, $storage, $internalPath, $result, $mount, $owner); |
1633 | 1633 | } |
@@ -1645,8 +1645,8 @@ discard block |
||
1645 | 1645 | if ($results) { |
1646 | 1646 | foreach ($results as $result) { |
1647 | 1647 | $internalPath = $result['path']; |
1648 | - $result['path'] = rtrim($relativeMountPoint . $result['path'], '/'); |
|
1649 | - $path = rtrim($mountPoint . $internalPath, '/'); |
|
1648 | + $result['path'] = rtrim($relativeMountPoint.$result['path'], '/'); |
|
1649 | + $path = rtrim($mountPoint.$internalPath, '/'); |
|
1650 | 1650 | $owner = $userManager->get($storage->getOwner($internalPath)); |
1651 | 1651 | $files[] = new FileInfo($path, $storage, $internalPath, $result, $mount, $owner); |
1652 | 1652 | } |
@@ -1667,11 +1667,11 @@ discard block |
||
1667 | 1667 | public function getOwner($path) { |
1668 | 1668 | $info = $this->getFileInfo($path); |
1669 | 1669 | if (!$info) { |
1670 | - throw new NotFoundException($path . ' not found while trying to get owner'); |
|
1670 | + throw new NotFoundException($path.' not found while trying to get owner'); |
|
1671 | 1671 | } |
1672 | 1672 | |
1673 | 1673 | if ($info->getOwner() === null) { |
1674 | - throw new NotFoundException($path . ' has no owner'); |
|
1674 | + throw new NotFoundException($path.' has no owner'); |
|
1675 | 1675 | } |
1676 | 1676 | |
1677 | 1677 | return $info->getOwner()->getUID(); |
@@ -1703,7 +1703,7 @@ discard block |
||
1703 | 1703 | * @throws NotFoundException |
1704 | 1704 | */ |
1705 | 1705 | public function getPath($id, int $storageId = null) { |
1706 | - $id = (int)$id; |
|
1706 | + $id = (int) $id; |
|
1707 | 1707 | $manager = Filesystem::getMountManager(); |
1708 | 1708 | $mounts = $manager->findIn($this->fakeRoot); |
1709 | 1709 | $mounts[] = $manager->find($this->fakeRoot); |
@@ -1714,12 +1714,12 @@ discard block |
||
1714 | 1714 | |
1715 | 1715 | // put non-shared mounts in front of the shared mount |
1716 | 1716 | // this prevents unneeded recursion into shares |
1717 | - usort($mounts, function (IMountPoint $a, IMountPoint $b) { |
|
1717 | + usort($mounts, function(IMountPoint $a, IMountPoint $b) { |
|
1718 | 1718 | return $a instanceof SharedMount && (!$b instanceof SharedMount) ? 1 : -1; |
1719 | 1719 | }); |
1720 | 1720 | |
1721 | 1721 | if (!is_null($storageId)) { |
1722 | - $mounts = array_filter($mounts, function (IMountPoint $mount) use ($storageId) { |
|
1722 | + $mounts = array_filter($mounts, function(IMountPoint $mount) use ($storageId) { |
|
1723 | 1723 | return $mount->getNumericStorageId() === $storageId; |
1724 | 1724 | }); |
1725 | 1725 | } |
@@ -1732,7 +1732,7 @@ discard block |
||
1732 | 1732 | $cache = $mount->getStorage()->getCache(); |
1733 | 1733 | $internalPath = $cache->getPathById($id); |
1734 | 1734 | if (is_string($internalPath)) { |
1735 | - $fullPath = $mount->getMountPoint() . $internalPath; |
|
1735 | + $fullPath = $mount->getMountPoint().$internalPath; |
|
1736 | 1736 | if (!is_null($path = $this->getRelativePath($fullPath))) { |
1737 | 1737 | return $path; |
1738 | 1738 | } |
@@ -1772,7 +1772,7 @@ discard block |
||
1772 | 1772 | // check if any of the parents were shared by the current owner (include collections) |
1773 | 1773 | $shares = Share::getItemShared( |
1774 | 1774 | 'folder', |
1775 | - (string)$fileId, |
|
1775 | + (string) $fileId, |
|
1776 | 1776 | \OC\Share\Constants::FORMAT_NONE, |
1777 | 1777 | null, |
1778 | 1778 | true |
@@ -1863,7 +1863,7 @@ discard block |
||
1863 | 1863 | $resultPath = ''; |
1864 | 1864 | foreach ($parts as $part) { |
1865 | 1865 | if ($part) { |
1866 | - $resultPath .= '/' . $part; |
|
1866 | + $resultPath .= '/'.$part; |
|
1867 | 1867 | $result[] = $resultPath; |
1868 | 1868 | } |
1869 | 1869 | } |
@@ -2122,16 +2122,16 @@ discard block |
||
2122 | 2122 | public function getUidAndFilename($filename) { |
2123 | 2123 | $info = $this->getFileInfo($filename); |
2124 | 2124 | if (!$info instanceof \OCP\Files\FileInfo) { |
2125 | - throw new NotFoundException($this->getAbsolutePath($filename) . ' not found'); |
|
2125 | + throw new NotFoundException($this->getAbsolutePath($filename).' not found'); |
|
2126 | 2126 | } |
2127 | 2127 | $uid = $info->getOwner()->getUID(); |
2128 | 2128 | if ($uid != \OC_User::getUser()) { |
2129 | 2129 | Filesystem::initMountPoints($uid); |
2130 | - $ownerView = new View('/' . $uid . '/files'); |
|
2130 | + $ownerView = new View('/'.$uid.'/files'); |
|
2131 | 2131 | try { |
2132 | 2132 | $filename = $ownerView->getPath($info['fileid']); |
2133 | 2133 | } catch (NotFoundException $e) { |
2134 | - throw new NotFoundException('File with id ' . $info['fileid'] . ' not found for user ' . $uid); |
|
2134 | + throw new NotFoundException('File with id '.$info['fileid'].' not found for user '.$uid); |
|
2135 | 2135 | } |
2136 | 2136 | } |
2137 | 2137 | return [$uid, $filename]; |
@@ -2148,7 +2148,7 @@ discard block |
||
2148 | 2148 | $directoryParts = array_filter($directoryParts); |
2149 | 2149 | foreach ($directoryParts as $key => $part) { |
2150 | 2150 | $currentPathElements = array_slice($directoryParts, 0, $key); |
2151 | - $currentPath = '/' . implode('/', $currentPathElements); |
|
2151 | + $currentPath = '/'.implode('/', $currentPathElements); |
|
2152 | 2152 | if ($this->is_file($currentPath)) { |
2153 | 2153 | return false; |
2154 | 2154 | } |