@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | // no point in continuing if the section was not found, use original path |
| 81 | 81 | return $fullPath; |
| 82 | 82 | } |
| 83 | - $path = $convertedPath . '/'; |
|
| 83 | + $path = $convertedPath.'/'; |
|
| 84 | 84 | } |
| 85 | 85 | $path = rtrim($path, '/'); |
| 86 | 86 | return $path; |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * @return string|null original or converted path, or null if none of the forms was found |
| 97 | 97 | */ |
| 98 | 98 | private function findPathToUseLastSection($basePath, $lastSection) { |
| 99 | - $fullPath = $basePath . $lastSection; |
|
| 99 | + $fullPath = $basePath.$lastSection; |
|
| 100 | 100 | if ($lastSection === '' || $this->isAscii($lastSection) || $this->storage->file_exists($fullPath)) { |
| 101 | 101 | $this->namesCache[$fullPath] = $fullPath; |
| 102 | 102 | return $fullPath; |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | } else { |
| 109 | 109 | $otherFormPath = \Normalizer::normalize($lastSection, \Normalizer::FORM_C); |
| 110 | 110 | } |
| 111 | - $otherFullPath = $basePath . $otherFormPath; |
|
| 111 | + $otherFullPath = $basePath.$otherFormPath; |
|
| 112 | 112 | if ($this->storage->file_exists($otherFullPath)) { |
| 113 | 113 | $this->namesCache[$fullPath] = $otherFullPath; |
| 114 | 114 | return $otherFullPath; |
@@ -41,509 +41,509 @@ |
||
| 41 | 41 | */ |
| 42 | 42 | class Encoding extends Wrapper { |
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @var ICache |
|
| 46 | - */ |
|
| 47 | - private $namesCache; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * @param array $parameters |
|
| 51 | - */ |
|
| 52 | - public function __construct($parameters) { |
|
| 53 | - $this->storage = $parameters['storage']; |
|
| 54 | - $this->namesCache = new CappedMemoryCache(); |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * Returns whether the given string is only made of ASCII characters |
|
| 59 | - * |
|
| 60 | - * @param string $str string |
|
| 61 | - * |
|
| 62 | - * @return bool true if the string is all ASCII, false otherwise |
|
| 63 | - */ |
|
| 64 | - private function isAscii($str) { |
|
| 65 | - return !preg_match('/[\\x80-\\xff]+/', $str); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * Checks whether the given path exists in NFC or NFD form after checking |
|
| 70 | - * each form for each path section and returns the correct form. |
|
| 71 | - * If no existing path found, returns the path as it was given. |
|
| 72 | - * |
|
| 73 | - * @param string $fullPath path to check |
|
| 74 | - * |
|
| 75 | - * @return string original or converted path |
|
| 76 | - */ |
|
| 77 | - private function findPathToUse($fullPath) { |
|
| 78 | - $cachedPath = $this->namesCache[$fullPath]; |
|
| 79 | - if ($cachedPath !== null) { |
|
| 80 | - return $cachedPath; |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - $sections = explode('/', $fullPath); |
|
| 84 | - $path = ''; |
|
| 85 | - foreach ($sections as $section) { |
|
| 86 | - $convertedPath = $this->findPathToUseLastSection($path, $section); |
|
| 87 | - if ($convertedPath === null) { |
|
| 88 | - // no point in continuing if the section was not found, use original path |
|
| 89 | - return $fullPath; |
|
| 90 | - } |
|
| 91 | - $path = $convertedPath . '/'; |
|
| 92 | - } |
|
| 93 | - $path = rtrim($path, '/'); |
|
| 94 | - return $path; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * Checks whether the last path section of the given path exists in NFC or NFD form |
|
| 99 | - * and returns the correct form. If no existing path found, returns null. |
|
| 100 | - * |
|
| 101 | - * @param string $basePath base path to check |
|
| 102 | - * @param string $lastSection last section of the path to check for NFD/NFC variations |
|
| 103 | - * |
|
| 104 | - * @return string|null original or converted path, or null if none of the forms was found |
|
| 105 | - */ |
|
| 106 | - private function findPathToUseLastSection($basePath, $lastSection) { |
|
| 107 | - $fullPath = $basePath . $lastSection; |
|
| 108 | - if ($lastSection === '' || $this->isAscii($lastSection) || $this->storage->file_exists($fullPath)) { |
|
| 109 | - $this->namesCache[$fullPath] = $fullPath; |
|
| 110 | - return $fullPath; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - // swap encoding |
|
| 114 | - if (\Normalizer::isNormalized($lastSection, \Normalizer::FORM_C)) { |
|
| 115 | - $otherFormPath = \Normalizer::normalize($lastSection, \Normalizer::FORM_D); |
|
| 116 | - } else { |
|
| 117 | - $otherFormPath = \Normalizer::normalize($lastSection, \Normalizer::FORM_C); |
|
| 118 | - } |
|
| 119 | - $otherFullPath = $basePath . $otherFormPath; |
|
| 120 | - if ($this->storage->file_exists($otherFullPath)) { |
|
| 121 | - $this->namesCache[$fullPath] = $otherFullPath; |
|
| 122 | - return $otherFullPath; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - // return original path, file did not exist at all |
|
| 126 | - $this->namesCache[$fullPath] = $fullPath; |
|
| 127 | - return null; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * see https://www.php.net/manual/en/function.mkdir.php |
|
| 132 | - * |
|
| 133 | - * @param string $path |
|
| 134 | - * @return bool |
|
| 135 | - */ |
|
| 136 | - public function mkdir($path) { |
|
| 137 | - // note: no conversion here, method should not be called with non-NFC names! |
|
| 138 | - $result = $this->storage->mkdir($path); |
|
| 139 | - if ($result) { |
|
| 140 | - $this->namesCache[$path] = $path; |
|
| 141 | - } |
|
| 142 | - return $result; |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - /** |
|
| 146 | - * see https://www.php.net/manual/en/function.rmdir.php |
|
| 147 | - * |
|
| 148 | - * @param string $path |
|
| 149 | - * @return bool |
|
| 150 | - */ |
|
| 151 | - public function rmdir($path) { |
|
| 152 | - $result = $this->storage->rmdir($this->findPathToUse($path)); |
|
| 153 | - if ($result) { |
|
| 154 | - unset($this->namesCache[$path]); |
|
| 155 | - } |
|
| 156 | - return $result; |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * see https://www.php.net/manual/en/function.opendir.php |
|
| 161 | - * |
|
| 162 | - * @param string $path |
|
| 163 | - * @return resource|bool |
|
| 164 | - */ |
|
| 165 | - public function opendir($path) { |
|
| 166 | - $handle = $this->storage->opendir($this->findPathToUse($path)); |
|
| 167 | - return EncodingDirectoryWrapper::wrap($handle); |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - /** |
|
| 171 | - * see https://www.php.net/manual/en/function.is_dir.php |
|
| 172 | - * |
|
| 173 | - * @param string $path |
|
| 174 | - * @return bool |
|
| 175 | - */ |
|
| 176 | - public function is_dir($path) { |
|
| 177 | - return $this->storage->is_dir($this->findPathToUse($path)); |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - /** |
|
| 181 | - * see https://www.php.net/manual/en/function.is_file.php |
|
| 182 | - * |
|
| 183 | - * @param string $path |
|
| 184 | - * @return bool |
|
| 185 | - */ |
|
| 186 | - public function is_file($path) { |
|
| 187 | - return $this->storage->is_file($this->findPathToUse($path)); |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * see https://www.php.net/manual/en/function.stat.php |
|
| 192 | - * only the following keys are required in the result: size and mtime |
|
| 193 | - * |
|
| 194 | - * @param string $path |
|
| 195 | - * @return array|bool |
|
| 196 | - */ |
|
| 197 | - public function stat($path) { |
|
| 198 | - return $this->storage->stat($this->findPathToUse($path)); |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - /** |
|
| 202 | - * see https://www.php.net/manual/en/function.filetype.php |
|
| 203 | - * |
|
| 204 | - * @param string $path |
|
| 205 | - * @return string|bool |
|
| 206 | - */ |
|
| 207 | - public function filetype($path) { |
|
| 208 | - return $this->storage->filetype($this->findPathToUse($path)); |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - /** |
|
| 212 | - * see https://www.php.net/manual/en/function.filesize.php |
|
| 213 | - * The result for filesize when called on a folder is required to be 0 |
|
| 214 | - * |
|
| 215 | - * @param string $path |
|
| 216 | - * @return int|bool |
|
| 217 | - */ |
|
| 218 | - public function filesize($path) { |
|
| 219 | - return $this->storage->filesize($this->findPathToUse($path)); |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - /** |
|
| 223 | - * check if a file can be created in $path |
|
| 224 | - * |
|
| 225 | - * @param string $path |
|
| 226 | - * @return bool |
|
| 227 | - */ |
|
| 228 | - public function isCreatable($path) { |
|
| 229 | - return $this->storage->isCreatable($this->findPathToUse($path)); |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - /** |
|
| 233 | - * check if a file can be read |
|
| 234 | - * |
|
| 235 | - * @param string $path |
|
| 236 | - * @return bool |
|
| 237 | - */ |
|
| 238 | - public function isReadable($path) { |
|
| 239 | - return $this->storage->isReadable($this->findPathToUse($path)); |
|
| 240 | - } |
|
| 241 | - |
|
| 242 | - /** |
|
| 243 | - * check if a file can be written to |
|
| 244 | - * |
|
| 245 | - * @param string $path |
|
| 246 | - * @return bool |
|
| 247 | - */ |
|
| 248 | - public function isUpdatable($path) { |
|
| 249 | - return $this->storage->isUpdatable($this->findPathToUse($path)); |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * check if a file can be deleted |
|
| 254 | - * |
|
| 255 | - * @param string $path |
|
| 256 | - * @return bool |
|
| 257 | - */ |
|
| 258 | - public function isDeletable($path) { |
|
| 259 | - return $this->storage->isDeletable($this->findPathToUse($path)); |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - /** |
|
| 263 | - * check if a file can be shared |
|
| 264 | - * |
|
| 265 | - * @param string $path |
|
| 266 | - * @return bool |
|
| 267 | - */ |
|
| 268 | - public function isSharable($path) { |
|
| 269 | - return $this->storage->isSharable($this->findPathToUse($path)); |
|
| 270 | - } |
|
| 271 | - |
|
| 272 | - /** |
|
| 273 | - * get the full permissions of a path. |
|
| 274 | - * Should return a combination of the PERMISSION_ constants defined in lib/public/constants.php |
|
| 275 | - * |
|
| 276 | - * @param string $path |
|
| 277 | - * @return int |
|
| 278 | - */ |
|
| 279 | - public function getPermissions($path) { |
|
| 280 | - return $this->storage->getPermissions($this->findPathToUse($path)); |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - /** |
|
| 284 | - * see https://www.php.net/manual/en/function.file_exists.php |
|
| 285 | - * |
|
| 286 | - * @param string $path |
|
| 287 | - * @return bool |
|
| 288 | - */ |
|
| 289 | - public function file_exists($path) { |
|
| 290 | - return $this->storage->file_exists($this->findPathToUse($path)); |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - /** |
|
| 294 | - * see https://www.php.net/manual/en/function.filemtime.php |
|
| 295 | - * |
|
| 296 | - * @param string $path |
|
| 297 | - * @return int|bool |
|
| 298 | - */ |
|
| 299 | - public function filemtime($path) { |
|
| 300 | - return $this->storage->filemtime($this->findPathToUse($path)); |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - /** |
|
| 304 | - * see https://www.php.net/manual/en/function.file_get_contents.php |
|
| 305 | - * |
|
| 306 | - * @param string $path |
|
| 307 | - * @return string|bool |
|
| 308 | - */ |
|
| 309 | - public function file_get_contents($path) { |
|
| 310 | - return $this->storage->file_get_contents($this->findPathToUse($path)); |
|
| 311 | - } |
|
| 312 | - |
|
| 313 | - /** |
|
| 314 | - * see https://www.php.net/manual/en/function.file_put_contents.php |
|
| 315 | - * |
|
| 316 | - * @param string $path |
|
| 317 | - * @param mixed $data |
|
| 318 | - * @return int|false |
|
| 319 | - */ |
|
| 320 | - public function file_put_contents($path, $data) { |
|
| 321 | - return $this->storage->file_put_contents($this->findPathToUse($path), $data); |
|
| 322 | - } |
|
| 323 | - |
|
| 324 | - /** |
|
| 325 | - * see https://www.php.net/manual/en/function.unlink.php |
|
| 326 | - * |
|
| 327 | - * @param string $path |
|
| 328 | - * @return bool |
|
| 329 | - */ |
|
| 330 | - public function unlink($path) { |
|
| 331 | - $result = $this->storage->unlink($this->findPathToUse($path)); |
|
| 332 | - if ($result) { |
|
| 333 | - unset($this->namesCache[$path]); |
|
| 334 | - } |
|
| 335 | - return $result; |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - /** |
|
| 339 | - * see https://www.php.net/manual/en/function.rename.php |
|
| 340 | - * |
|
| 341 | - * @param string $path1 |
|
| 342 | - * @param string $path2 |
|
| 343 | - * @return bool |
|
| 344 | - */ |
|
| 345 | - public function rename($path1, $path2) { |
|
| 346 | - // second name always NFC |
|
| 347 | - return $this->storage->rename($this->findPathToUse($path1), $this->findPathToUse($path2)); |
|
| 348 | - } |
|
| 349 | - |
|
| 350 | - /** |
|
| 351 | - * see https://www.php.net/manual/en/function.copy.php |
|
| 352 | - * |
|
| 353 | - * @param string $path1 |
|
| 354 | - * @param string $path2 |
|
| 355 | - * @return bool |
|
| 356 | - */ |
|
| 357 | - public function copy($path1, $path2) { |
|
| 358 | - return $this->storage->copy($this->findPathToUse($path1), $this->findPathToUse($path2)); |
|
| 359 | - } |
|
| 360 | - |
|
| 361 | - /** |
|
| 362 | - * see https://www.php.net/manual/en/function.fopen.php |
|
| 363 | - * |
|
| 364 | - * @param string $path |
|
| 365 | - * @param string $mode |
|
| 366 | - * @return resource|bool |
|
| 367 | - */ |
|
| 368 | - public function fopen($path, $mode) { |
|
| 369 | - $result = $this->storage->fopen($this->findPathToUse($path), $mode); |
|
| 370 | - if ($result && $mode !== 'r' && $mode !== 'rb') { |
|
| 371 | - unset($this->namesCache[$path]); |
|
| 372 | - } |
|
| 373 | - return $result; |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - /** |
|
| 377 | - * get the mimetype for a file or folder |
|
| 378 | - * The mimetype for a folder is required to be "httpd/unix-directory" |
|
| 379 | - * |
|
| 380 | - * @param string $path |
|
| 381 | - * @return string|bool |
|
| 382 | - */ |
|
| 383 | - public function getMimeType($path) { |
|
| 384 | - return $this->storage->getMimeType($this->findPathToUse($path)); |
|
| 385 | - } |
|
| 386 | - |
|
| 387 | - /** |
|
| 388 | - * see https://www.php.net/manual/en/function.hash.php |
|
| 389 | - * |
|
| 390 | - * @param string $type |
|
| 391 | - * @param string $path |
|
| 392 | - * @param bool $raw |
|
| 393 | - * @return string|bool |
|
| 394 | - */ |
|
| 395 | - public function hash($type, $path, $raw = false) { |
|
| 396 | - return $this->storage->hash($type, $this->findPathToUse($path), $raw); |
|
| 397 | - } |
|
| 398 | - |
|
| 399 | - /** |
|
| 400 | - * see https://www.php.net/manual/en/function.free_space.php |
|
| 401 | - * |
|
| 402 | - * @param string $path |
|
| 403 | - * @return int|bool |
|
| 404 | - */ |
|
| 405 | - public function free_space($path) { |
|
| 406 | - return $this->storage->free_space($this->findPathToUse($path)); |
|
| 407 | - } |
|
| 408 | - |
|
| 409 | - /** |
|
| 410 | - * search for occurrences of $query in file names |
|
| 411 | - * |
|
| 412 | - * @param string $query |
|
| 413 | - * @return array|bool |
|
| 414 | - */ |
|
| 415 | - public function search($query) { |
|
| 416 | - return $this->storage->search($query); |
|
| 417 | - } |
|
| 418 | - |
|
| 419 | - /** |
|
| 420 | - * see https://www.php.net/manual/en/function.touch.php |
|
| 421 | - * If the backend does not support the operation, false should be returned |
|
| 422 | - * |
|
| 423 | - * @param string $path |
|
| 424 | - * @param int $mtime |
|
| 425 | - * @return bool |
|
| 426 | - */ |
|
| 427 | - public function touch($path, $mtime = null) { |
|
| 428 | - return $this->storage->touch($this->findPathToUse($path), $mtime); |
|
| 429 | - } |
|
| 430 | - |
|
| 431 | - /** |
|
| 432 | - * get the path to a local version of the file. |
|
| 433 | - * The local version of the file can be temporary and doesn't have to be persistent across requests |
|
| 434 | - * |
|
| 435 | - * @param string $path |
|
| 436 | - * @return string|bool |
|
| 437 | - */ |
|
| 438 | - public function getLocalFile($path) { |
|
| 439 | - return $this->storage->getLocalFile($this->findPathToUse($path)); |
|
| 440 | - } |
|
| 441 | - |
|
| 442 | - /** |
|
| 443 | - * check if a file or folder has been updated since $time |
|
| 444 | - * |
|
| 445 | - * @param string $path |
|
| 446 | - * @param int $time |
|
| 447 | - * @return bool |
|
| 448 | - * |
|
| 449 | - * hasUpdated for folders should return at least true if a file inside the folder is add, removed or renamed. |
|
| 450 | - * returning true for other changes in the folder is optional |
|
| 451 | - */ |
|
| 452 | - public function hasUpdated($path, $time) { |
|
| 453 | - return $this->storage->hasUpdated($this->findPathToUse($path), $time); |
|
| 454 | - } |
|
| 455 | - |
|
| 456 | - /** |
|
| 457 | - * get a cache instance for the storage |
|
| 458 | - * |
|
| 459 | - * @param string $path |
|
| 460 | - * @param \OC\Files\Storage\Storage (optional) the storage to pass to the cache |
|
| 461 | - * @return \OC\Files\Cache\Cache |
|
| 462 | - */ |
|
| 463 | - public function getCache($path = '', $storage = null) { |
|
| 464 | - if (!$storage) { |
|
| 465 | - $storage = $this; |
|
| 466 | - } |
|
| 467 | - return $this->storage->getCache($this->findPathToUse($path), $storage); |
|
| 468 | - } |
|
| 469 | - |
|
| 470 | - /** |
|
| 471 | - * get a scanner instance for the storage |
|
| 472 | - * |
|
| 473 | - * @param string $path |
|
| 474 | - * @param \OC\Files\Storage\Storage (optional) the storage to pass to the scanner |
|
| 475 | - * @return \OC\Files\Cache\Scanner |
|
| 476 | - */ |
|
| 477 | - public function getScanner($path = '', $storage = null) { |
|
| 478 | - if (!$storage) { |
|
| 479 | - $storage = $this; |
|
| 480 | - } |
|
| 481 | - return $this->storage->getScanner($this->findPathToUse($path), $storage); |
|
| 482 | - } |
|
| 483 | - |
|
| 484 | - /** |
|
| 485 | - * get the ETag for a file or folder |
|
| 486 | - * |
|
| 487 | - * @param string $path |
|
| 488 | - * @return string|bool |
|
| 489 | - */ |
|
| 490 | - public function getETag($path) { |
|
| 491 | - return $this->storage->getETag($this->findPathToUse($path)); |
|
| 492 | - } |
|
| 493 | - |
|
| 494 | - /** |
|
| 495 | - * @param IStorage $sourceStorage |
|
| 496 | - * @param string $sourceInternalPath |
|
| 497 | - * @param string $targetInternalPath |
|
| 498 | - * @return bool |
|
| 499 | - */ |
|
| 500 | - public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { |
|
| 501 | - if ($sourceStorage === $this) { |
|
| 502 | - return $this->copy($sourceInternalPath, $this->findPathToUse($targetInternalPath)); |
|
| 503 | - } |
|
| 504 | - |
|
| 505 | - $result = $this->storage->copyFromStorage($sourceStorage, $sourceInternalPath, $this->findPathToUse($targetInternalPath)); |
|
| 506 | - if ($result) { |
|
| 507 | - unset($this->namesCache[$targetInternalPath]); |
|
| 508 | - } |
|
| 509 | - return $result; |
|
| 510 | - } |
|
| 511 | - |
|
| 512 | - /** |
|
| 513 | - * @param IStorage $sourceStorage |
|
| 514 | - * @param string $sourceInternalPath |
|
| 515 | - * @param string $targetInternalPath |
|
| 516 | - * @return bool |
|
| 517 | - */ |
|
| 518 | - public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { |
|
| 519 | - if ($sourceStorage === $this) { |
|
| 520 | - $result = $this->rename($sourceInternalPath, $this->findPathToUse($targetInternalPath)); |
|
| 521 | - if ($result) { |
|
| 522 | - unset($this->namesCache[$sourceInternalPath]); |
|
| 523 | - unset($this->namesCache[$targetInternalPath]); |
|
| 524 | - } |
|
| 525 | - return $result; |
|
| 526 | - } |
|
| 527 | - |
|
| 528 | - $result = $this->storage->moveFromStorage($sourceStorage, $sourceInternalPath, $this->findPathToUse($targetInternalPath)); |
|
| 529 | - if ($result) { |
|
| 530 | - unset($this->namesCache[$sourceInternalPath]); |
|
| 531 | - unset($this->namesCache[$targetInternalPath]); |
|
| 532 | - } |
|
| 533 | - return $result; |
|
| 534 | - } |
|
| 535 | - |
|
| 536 | - public function getMetaData($path) { |
|
| 537 | - $entry = $this->storage->getMetaData($this->findPathToUse($path)); |
|
| 538 | - $entry['name'] = trim(Filesystem::normalizePath($entry['name']), '/'); |
|
| 539 | - return $entry; |
|
| 540 | - } |
|
| 541 | - |
|
| 542 | - public function getDirectoryContent($directory): \Traversable { |
|
| 543 | - $entries = $this->storage->getDirectoryContent($this->findPathToUse($directory)); |
|
| 544 | - foreach ($entries as $entry) { |
|
| 545 | - $entry['name'] = trim(Filesystem::normalizePath($entry['name']), '/'); |
|
| 546 | - yield $entry; |
|
| 547 | - } |
|
| 548 | - } |
|
| 44 | + /** |
|
| 45 | + * @var ICache |
|
| 46 | + */ |
|
| 47 | + private $namesCache; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * @param array $parameters |
|
| 51 | + */ |
|
| 52 | + public function __construct($parameters) { |
|
| 53 | + $this->storage = $parameters['storage']; |
|
| 54 | + $this->namesCache = new CappedMemoryCache(); |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * Returns whether the given string is only made of ASCII characters |
|
| 59 | + * |
|
| 60 | + * @param string $str string |
|
| 61 | + * |
|
| 62 | + * @return bool true if the string is all ASCII, false otherwise |
|
| 63 | + */ |
|
| 64 | + private function isAscii($str) { |
|
| 65 | + return !preg_match('/[\\x80-\\xff]+/', $str); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * Checks whether the given path exists in NFC or NFD form after checking |
|
| 70 | + * each form for each path section and returns the correct form. |
|
| 71 | + * If no existing path found, returns the path as it was given. |
|
| 72 | + * |
|
| 73 | + * @param string $fullPath path to check |
|
| 74 | + * |
|
| 75 | + * @return string original or converted path |
|
| 76 | + */ |
|
| 77 | + private function findPathToUse($fullPath) { |
|
| 78 | + $cachedPath = $this->namesCache[$fullPath]; |
|
| 79 | + if ($cachedPath !== null) { |
|
| 80 | + return $cachedPath; |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + $sections = explode('/', $fullPath); |
|
| 84 | + $path = ''; |
|
| 85 | + foreach ($sections as $section) { |
|
| 86 | + $convertedPath = $this->findPathToUseLastSection($path, $section); |
|
| 87 | + if ($convertedPath === null) { |
|
| 88 | + // no point in continuing if the section was not found, use original path |
|
| 89 | + return $fullPath; |
|
| 90 | + } |
|
| 91 | + $path = $convertedPath . '/'; |
|
| 92 | + } |
|
| 93 | + $path = rtrim($path, '/'); |
|
| 94 | + return $path; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * Checks whether the last path section of the given path exists in NFC or NFD form |
|
| 99 | + * and returns the correct form. If no existing path found, returns null. |
|
| 100 | + * |
|
| 101 | + * @param string $basePath base path to check |
|
| 102 | + * @param string $lastSection last section of the path to check for NFD/NFC variations |
|
| 103 | + * |
|
| 104 | + * @return string|null original or converted path, or null if none of the forms was found |
|
| 105 | + */ |
|
| 106 | + private function findPathToUseLastSection($basePath, $lastSection) { |
|
| 107 | + $fullPath = $basePath . $lastSection; |
|
| 108 | + if ($lastSection === '' || $this->isAscii($lastSection) || $this->storage->file_exists($fullPath)) { |
|
| 109 | + $this->namesCache[$fullPath] = $fullPath; |
|
| 110 | + return $fullPath; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + // swap encoding |
|
| 114 | + if (\Normalizer::isNormalized($lastSection, \Normalizer::FORM_C)) { |
|
| 115 | + $otherFormPath = \Normalizer::normalize($lastSection, \Normalizer::FORM_D); |
|
| 116 | + } else { |
|
| 117 | + $otherFormPath = \Normalizer::normalize($lastSection, \Normalizer::FORM_C); |
|
| 118 | + } |
|
| 119 | + $otherFullPath = $basePath . $otherFormPath; |
|
| 120 | + if ($this->storage->file_exists($otherFullPath)) { |
|
| 121 | + $this->namesCache[$fullPath] = $otherFullPath; |
|
| 122 | + return $otherFullPath; |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + // return original path, file did not exist at all |
|
| 126 | + $this->namesCache[$fullPath] = $fullPath; |
|
| 127 | + return null; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * see https://www.php.net/manual/en/function.mkdir.php |
|
| 132 | + * |
|
| 133 | + * @param string $path |
|
| 134 | + * @return bool |
|
| 135 | + */ |
|
| 136 | + public function mkdir($path) { |
|
| 137 | + // note: no conversion here, method should not be called with non-NFC names! |
|
| 138 | + $result = $this->storage->mkdir($path); |
|
| 139 | + if ($result) { |
|
| 140 | + $this->namesCache[$path] = $path; |
|
| 141 | + } |
|
| 142 | + return $result; |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + /** |
|
| 146 | + * see https://www.php.net/manual/en/function.rmdir.php |
|
| 147 | + * |
|
| 148 | + * @param string $path |
|
| 149 | + * @return bool |
|
| 150 | + */ |
|
| 151 | + public function rmdir($path) { |
|
| 152 | + $result = $this->storage->rmdir($this->findPathToUse($path)); |
|
| 153 | + if ($result) { |
|
| 154 | + unset($this->namesCache[$path]); |
|
| 155 | + } |
|
| 156 | + return $result; |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * see https://www.php.net/manual/en/function.opendir.php |
|
| 161 | + * |
|
| 162 | + * @param string $path |
|
| 163 | + * @return resource|bool |
|
| 164 | + */ |
|
| 165 | + public function opendir($path) { |
|
| 166 | + $handle = $this->storage->opendir($this->findPathToUse($path)); |
|
| 167 | + return EncodingDirectoryWrapper::wrap($handle); |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + /** |
|
| 171 | + * see https://www.php.net/manual/en/function.is_dir.php |
|
| 172 | + * |
|
| 173 | + * @param string $path |
|
| 174 | + * @return bool |
|
| 175 | + */ |
|
| 176 | + public function is_dir($path) { |
|
| 177 | + return $this->storage->is_dir($this->findPathToUse($path)); |
|
| 178 | + } |
|
| 179 | + |
|
| 180 | + /** |
|
| 181 | + * see https://www.php.net/manual/en/function.is_file.php |
|
| 182 | + * |
|
| 183 | + * @param string $path |
|
| 184 | + * @return bool |
|
| 185 | + */ |
|
| 186 | + public function is_file($path) { |
|
| 187 | + return $this->storage->is_file($this->findPathToUse($path)); |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + /** |
|
| 191 | + * see https://www.php.net/manual/en/function.stat.php |
|
| 192 | + * only the following keys are required in the result: size and mtime |
|
| 193 | + * |
|
| 194 | + * @param string $path |
|
| 195 | + * @return array|bool |
|
| 196 | + */ |
|
| 197 | + public function stat($path) { |
|
| 198 | + return $this->storage->stat($this->findPathToUse($path)); |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + /** |
|
| 202 | + * see https://www.php.net/manual/en/function.filetype.php |
|
| 203 | + * |
|
| 204 | + * @param string $path |
|
| 205 | + * @return string|bool |
|
| 206 | + */ |
|
| 207 | + public function filetype($path) { |
|
| 208 | + return $this->storage->filetype($this->findPathToUse($path)); |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + /** |
|
| 212 | + * see https://www.php.net/manual/en/function.filesize.php |
|
| 213 | + * The result for filesize when called on a folder is required to be 0 |
|
| 214 | + * |
|
| 215 | + * @param string $path |
|
| 216 | + * @return int|bool |
|
| 217 | + */ |
|
| 218 | + public function filesize($path) { |
|
| 219 | + return $this->storage->filesize($this->findPathToUse($path)); |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + /** |
|
| 223 | + * check if a file can be created in $path |
|
| 224 | + * |
|
| 225 | + * @param string $path |
|
| 226 | + * @return bool |
|
| 227 | + */ |
|
| 228 | + public function isCreatable($path) { |
|
| 229 | + return $this->storage->isCreatable($this->findPathToUse($path)); |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + /** |
|
| 233 | + * check if a file can be read |
|
| 234 | + * |
|
| 235 | + * @param string $path |
|
| 236 | + * @return bool |
|
| 237 | + */ |
|
| 238 | + public function isReadable($path) { |
|
| 239 | + return $this->storage->isReadable($this->findPathToUse($path)); |
|
| 240 | + } |
|
| 241 | + |
|
| 242 | + /** |
|
| 243 | + * check if a file can be written to |
|
| 244 | + * |
|
| 245 | + * @param string $path |
|
| 246 | + * @return bool |
|
| 247 | + */ |
|
| 248 | + public function isUpdatable($path) { |
|
| 249 | + return $this->storage->isUpdatable($this->findPathToUse($path)); |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * check if a file can be deleted |
|
| 254 | + * |
|
| 255 | + * @param string $path |
|
| 256 | + * @return bool |
|
| 257 | + */ |
|
| 258 | + public function isDeletable($path) { |
|
| 259 | + return $this->storage->isDeletable($this->findPathToUse($path)); |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + /** |
|
| 263 | + * check if a file can be shared |
|
| 264 | + * |
|
| 265 | + * @param string $path |
|
| 266 | + * @return bool |
|
| 267 | + */ |
|
| 268 | + public function isSharable($path) { |
|
| 269 | + return $this->storage->isSharable($this->findPathToUse($path)); |
|
| 270 | + } |
|
| 271 | + |
|
| 272 | + /** |
|
| 273 | + * get the full permissions of a path. |
|
| 274 | + * Should return a combination of the PERMISSION_ constants defined in lib/public/constants.php |
|
| 275 | + * |
|
| 276 | + * @param string $path |
|
| 277 | + * @return int |
|
| 278 | + */ |
|
| 279 | + public function getPermissions($path) { |
|
| 280 | + return $this->storage->getPermissions($this->findPathToUse($path)); |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + /** |
|
| 284 | + * see https://www.php.net/manual/en/function.file_exists.php |
|
| 285 | + * |
|
| 286 | + * @param string $path |
|
| 287 | + * @return bool |
|
| 288 | + */ |
|
| 289 | + public function file_exists($path) { |
|
| 290 | + return $this->storage->file_exists($this->findPathToUse($path)); |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + /** |
|
| 294 | + * see https://www.php.net/manual/en/function.filemtime.php |
|
| 295 | + * |
|
| 296 | + * @param string $path |
|
| 297 | + * @return int|bool |
|
| 298 | + */ |
|
| 299 | + public function filemtime($path) { |
|
| 300 | + return $this->storage->filemtime($this->findPathToUse($path)); |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + /** |
|
| 304 | + * see https://www.php.net/manual/en/function.file_get_contents.php |
|
| 305 | + * |
|
| 306 | + * @param string $path |
|
| 307 | + * @return string|bool |
|
| 308 | + */ |
|
| 309 | + public function file_get_contents($path) { |
|
| 310 | + return $this->storage->file_get_contents($this->findPathToUse($path)); |
|
| 311 | + } |
|
| 312 | + |
|
| 313 | + /** |
|
| 314 | + * see https://www.php.net/manual/en/function.file_put_contents.php |
|
| 315 | + * |
|
| 316 | + * @param string $path |
|
| 317 | + * @param mixed $data |
|
| 318 | + * @return int|false |
|
| 319 | + */ |
|
| 320 | + public function file_put_contents($path, $data) { |
|
| 321 | + return $this->storage->file_put_contents($this->findPathToUse($path), $data); |
|
| 322 | + } |
|
| 323 | + |
|
| 324 | + /** |
|
| 325 | + * see https://www.php.net/manual/en/function.unlink.php |
|
| 326 | + * |
|
| 327 | + * @param string $path |
|
| 328 | + * @return bool |
|
| 329 | + */ |
|
| 330 | + public function unlink($path) { |
|
| 331 | + $result = $this->storage->unlink($this->findPathToUse($path)); |
|
| 332 | + if ($result) { |
|
| 333 | + unset($this->namesCache[$path]); |
|
| 334 | + } |
|
| 335 | + return $result; |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + /** |
|
| 339 | + * see https://www.php.net/manual/en/function.rename.php |
|
| 340 | + * |
|
| 341 | + * @param string $path1 |
|
| 342 | + * @param string $path2 |
|
| 343 | + * @return bool |
|
| 344 | + */ |
|
| 345 | + public function rename($path1, $path2) { |
|
| 346 | + // second name always NFC |
|
| 347 | + return $this->storage->rename($this->findPathToUse($path1), $this->findPathToUse($path2)); |
|
| 348 | + } |
|
| 349 | + |
|
| 350 | + /** |
|
| 351 | + * see https://www.php.net/manual/en/function.copy.php |
|
| 352 | + * |
|
| 353 | + * @param string $path1 |
|
| 354 | + * @param string $path2 |
|
| 355 | + * @return bool |
|
| 356 | + */ |
|
| 357 | + public function copy($path1, $path2) { |
|
| 358 | + return $this->storage->copy($this->findPathToUse($path1), $this->findPathToUse($path2)); |
|
| 359 | + } |
|
| 360 | + |
|
| 361 | + /** |
|
| 362 | + * see https://www.php.net/manual/en/function.fopen.php |
|
| 363 | + * |
|
| 364 | + * @param string $path |
|
| 365 | + * @param string $mode |
|
| 366 | + * @return resource|bool |
|
| 367 | + */ |
|
| 368 | + public function fopen($path, $mode) { |
|
| 369 | + $result = $this->storage->fopen($this->findPathToUse($path), $mode); |
|
| 370 | + if ($result && $mode !== 'r' && $mode !== 'rb') { |
|
| 371 | + unset($this->namesCache[$path]); |
|
| 372 | + } |
|
| 373 | + return $result; |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + /** |
|
| 377 | + * get the mimetype for a file or folder |
|
| 378 | + * The mimetype for a folder is required to be "httpd/unix-directory" |
|
| 379 | + * |
|
| 380 | + * @param string $path |
|
| 381 | + * @return string|bool |
|
| 382 | + */ |
|
| 383 | + public function getMimeType($path) { |
|
| 384 | + return $this->storage->getMimeType($this->findPathToUse($path)); |
|
| 385 | + } |
|
| 386 | + |
|
| 387 | + /** |
|
| 388 | + * see https://www.php.net/manual/en/function.hash.php |
|
| 389 | + * |
|
| 390 | + * @param string $type |
|
| 391 | + * @param string $path |
|
| 392 | + * @param bool $raw |
|
| 393 | + * @return string|bool |
|
| 394 | + */ |
|
| 395 | + public function hash($type, $path, $raw = false) { |
|
| 396 | + return $this->storage->hash($type, $this->findPathToUse($path), $raw); |
|
| 397 | + } |
|
| 398 | + |
|
| 399 | + /** |
|
| 400 | + * see https://www.php.net/manual/en/function.free_space.php |
|
| 401 | + * |
|
| 402 | + * @param string $path |
|
| 403 | + * @return int|bool |
|
| 404 | + */ |
|
| 405 | + public function free_space($path) { |
|
| 406 | + return $this->storage->free_space($this->findPathToUse($path)); |
|
| 407 | + } |
|
| 408 | + |
|
| 409 | + /** |
|
| 410 | + * search for occurrences of $query in file names |
|
| 411 | + * |
|
| 412 | + * @param string $query |
|
| 413 | + * @return array|bool |
|
| 414 | + */ |
|
| 415 | + public function search($query) { |
|
| 416 | + return $this->storage->search($query); |
|
| 417 | + } |
|
| 418 | + |
|
| 419 | + /** |
|
| 420 | + * see https://www.php.net/manual/en/function.touch.php |
|
| 421 | + * If the backend does not support the operation, false should be returned |
|
| 422 | + * |
|
| 423 | + * @param string $path |
|
| 424 | + * @param int $mtime |
|
| 425 | + * @return bool |
|
| 426 | + */ |
|
| 427 | + public function touch($path, $mtime = null) { |
|
| 428 | + return $this->storage->touch($this->findPathToUse($path), $mtime); |
|
| 429 | + } |
|
| 430 | + |
|
| 431 | + /** |
|
| 432 | + * get the path to a local version of the file. |
|
| 433 | + * The local version of the file can be temporary and doesn't have to be persistent across requests |
|
| 434 | + * |
|
| 435 | + * @param string $path |
|
| 436 | + * @return string|bool |
|
| 437 | + */ |
|
| 438 | + public function getLocalFile($path) { |
|
| 439 | + return $this->storage->getLocalFile($this->findPathToUse($path)); |
|
| 440 | + } |
|
| 441 | + |
|
| 442 | + /** |
|
| 443 | + * check if a file or folder has been updated since $time |
|
| 444 | + * |
|
| 445 | + * @param string $path |
|
| 446 | + * @param int $time |
|
| 447 | + * @return bool |
|
| 448 | + * |
|
| 449 | + * hasUpdated for folders should return at least true if a file inside the folder is add, removed or renamed. |
|
| 450 | + * returning true for other changes in the folder is optional |
|
| 451 | + */ |
|
| 452 | + public function hasUpdated($path, $time) { |
|
| 453 | + return $this->storage->hasUpdated($this->findPathToUse($path), $time); |
|
| 454 | + } |
|
| 455 | + |
|
| 456 | + /** |
|
| 457 | + * get a cache instance for the storage |
|
| 458 | + * |
|
| 459 | + * @param string $path |
|
| 460 | + * @param \OC\Files\Storage\Storage (optional) the storage to pass to the cache |
|
| 461 | + * @return \OC\Files\Cache\Cache |
|
| 462 | + */ |
|
| 463 | + public function getCache($path = '', $storage = null) { |
|
| 464 | + if (!$storage) { |
|
| 465 | + $storage = $this; |
|
| 466 | + } |
|
| 467 | + return $this->storage->getCache($this->findPathToUse($path), $storage); |
|
| 468 | + } |
|
| 469 | + |
|
| 470 | + /** |
|
| 471 | + * get a scanner instance for the storage |
|
| 472 | + * |
|
| 473 | + * @param string $path |
|
| 474 | + * @param \OC\Files\Storage\Storage (optional) the storage to pass to the scanner |
|
| 475 | + * @return \OC\Files\Cache\Scanner |
|
| 476 | + */ |
|
| 477 | + public function getScanner($path = '', $storage = null) { |
|
| 478 | + if (!$storage) { |
|
| 479 | + $storage = $this; |
|
| 480 | + } |
|
| 481 | + return $this->storage->getScanner($this->findPathToUse($path), $storage); |
|
| 482 | + } |
|
| 483 | + |
|
| 484 | + /** |
|
| 485 | + * get the ETag for a file or folder |
|
| 486 | + * |
|
| 487 | + * @param string $path |
|
| 488 | + * @return string|bool |
|
| 489 | + */ |
|
| 490 | + public function getETag($path) { |
|
| 491 | + return $this->storage->getETag($this->findPathToUse($path)); |
|
| 492 | + } |
|
| 493 | + |
|
| 494 | + /** |
|
| 495 | + * @param IStorage $sourceStorage |
|
| 496 | + * @param string $sourceInternalPath |
|
| 497 | + * @param string $targetInternalPath |
|
| 498 | + * @return bool |
|
| 499 | + */ |
|
| 500 | + public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { |
|
| 501 | + if ($sourceStorage === $this) { |
|
| 502 | + return $this->copy($sourceInternalPath, $this->findPathToUse($targetInternalPath)); |
|
| 503 | + } |
|
| 504 | + |
|
| 505 | + $result = $this->storage->copyFromStorage($sourceStorage, $sourceInternalPath, $this->findPathToUse($targetInternalPath)); |
|
| 506 | + if ($result) { |
|
| 507 | + unset($this->namesCache[$targetInternalPath]); |
|
| 508 | + } |
|
| 509 | + return $result; |
|
| 510 | + } |
|
| 511 | + |
|
| 512 | + /** |
|
| 513 | + * @param IStorage $sourceStorage |
|
| 514 | + * @param string $sourceInternalPath |
|
| 515 | + * @param string $targetInternalPath |
|
| 516 | + * @return bool |
|
| 517 | + */ |
|
| 518 | + public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { |
|
| 519 | + if ($sourceStorage === $this) { |
|
| 520 | + $result = $this->rename($sourceInternalPath, $this->findPathToUse($targetInternalPath)); |
|
| 521 | + if ($result) { |
|
| 522 | + unset($this->namesCache[$sourceInternalPath]); |
|
| 523 | + unset($this->namesCache[$targetInternalPath]); |
|
| 524 | + } |
|
| 525 | + return $result; |
|
| 526 | + } |
|
| 527 | + |
|
| 528 | + $result = $this->storage->moveFromStorage($sourceStorage, $sourceInternalPath, $this->findPathToUse($targetInternalPath)); |
|
| 529 | + if ($result) { |
|
| 530 | + unset($this->namesCache[$sourceInternalPath]); |
|
| 531 | + unset($this->namesCache[$targetInternalPath]); |
|
| 532 | + } |
|
| 533 | + return $result; |
|
| 534 | + } |
|
| 535 | + |
|
| 536 | + public function getMetaData($path) { |
|
| 537 | + $entry = $this->storage->getMetaData($this->findPathToUse($path)); |
|
| 538 | + $entry['name'] = trim(Filesystem::normalizePath($entry['name']), '/'); |
|
| 539 | + return $entry; |
|
| 540 | + } |
|
| 541 | + |
|
| 542 | + public function getDirectoryContent($directory): \Traversable { |
|
| 543 | + $entries = $this->storage->getDirectoryContent($this->findPathToUse($directory)); |
|
| 544 | + foreach ($entries as $entry) { |
|
| 545 | + $entry['name'] = trim(Filesystem::normalizePath($entry['name']), '/'); |
|
| 546 | + yield $entry; |
|
| 547 | + } |
|
| 548 | + } |
|
| 549 | 549 | } |
@@ -37,45 +37,45 @@ |
||
| 37 | 37 | */ |
| 38 | 38 | trait LocalTempFileTrait { |
| 39 | 39 | |
| 40 | - /** @var string[] */ |
|
| 41 | - protected $cachedFiles = []; |
|
| 40 | + /** @var string[] */ |
|
| 41 | + protected $cachedFiles = []; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @param string $path |
|
| 45 | - * @return string |
|
| 46 | - */ |
|
| 47 | - protected function getCachedFile($path) { |
|
| 48 | - if (!isset($this->cachedFiles[$path])) { |
|
| 49 | - $this->cachedFiles[$path] = $this->toTmpFile($path); |
|
| 50 | - } |
|
| 51 | - return $this->cachedFiles[$path]; |
|
| 52 | - } |
|
| 43 | + /** |
|
| 44 | + * @param string $path |
|
| 45 | + * @return string |
|
| 46 | + */ |
|
| 47 | + protected function getCachedFile($path) { |
|
| 48 | + if (!isset($this->cachedFiles[$path])) { |
|
| 49 | + $this->cachedFiles[$path] = $this->toTmpFile($path); |
|
| 50 | + } |
|
| 51 | + return $this->cachedFiles[$path]; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @param string $path |
|
| 56 | - */ |
|
| 57 | - protected function removeCachedFile($path) { |
|
| 58 | - unset($this->cachedFiles[$path]); |
|
| 59 | - } |
|
| 54 | + /** |
|
| 55 | + * @param string $path |
|
| 56 | + */ |
|
| 57 | + protected function removeCachedFile($path) { |
|
| 58 | + unset($this->cachedFiles[$path]); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * @param string $path |
|
| 63 | - * @return string |
|
| 64 | - */ |
|
| 65 | - protected function toTmpFile($path) { //no longer in the storage api, still useful here |
|
| 66 | - $source = $this->fopen($path, 'r'); |
|
| 67 | - if (!$source) { |
|
| 68 | - return false; |
|
| 69 | - } |
|
| 70 | - if ($pos = strrpos($path, '.')) { |
|
| 71 | - $extension = substr($path, $pos); |
|
| 72 | - } else { |
|
| 73 | - $extension = ''; |
|
| 74 | - } |
|
| 75 | - $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($extension); |
|
| 76 | - $target = fopen($tmpFile, 'w'); |
|
| 77 | - \OC_Helper::streamCopy($source, $target); |
|
| 78 | - fclose($target); |
|
| 79 | - return $tmpFile; |
|
| 80 | - } |
|
| 61 | + /** |
|
| 62 | + * @param string $path |
|
| 63 | + * @return string |
|
| 64 | + */ |
|
| 65 | + protected function toTmpFile($path) { //no longer in the storage api, still useful here |
|
| 66 | + $source = $this->fopen($path, 'r'); |
|
| 67 | + if (!$source) { |
|
| 68 | + return false; |
|
| 69 | + } |
|
| 70 | + if ($pos = strrpos($path, '.')) { |
|
| 71 | + $extension = substr($path, $pos); |
|
| 72 | + } else { |
|
| 73 | + $extension = ''; |
|
| 74 | + } |
|
| 75 | + $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($extension); |
|
| 76 | + $target = fopen($tmpFile, 'w'); |
|
| 77 | + \OC_Helper::streamCopy($source, $target); |
|
| 78 | + fclose($target); |
|
| 79 | + return $tmpFile; |
|
| 80 | + } |
|
| 81 | 81 | } |
@@ -29,80 +29,80 @@ |
||
| 29 | 29 | use OCP\Files\Storage\IStorageFactory; |
| 30 | 30 | |
| 31 | 31 | class StorageFactory implements IStorageFactory { |
| 32 | - /** |
|
| 33 | - * @var array[] [$name=>['priority'=>$priority, 'wrapper'=>$callable] $storageWrappers |
|
| 34 | - */ |
|
| 35 | - private $storageWrappers = []; |
|
| 32 | + /** |
|
| 33 | + * @var array[] [$name=>['priority'=>$priority, 'wrapper'=>$callable] $storageWrappers |
|
| 34 | + */ |
|
| 35 | + private $storageWrappers = []; |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * allow modifier storage behaviour by adding wrappers around storages |
|
| 39 | - * |
|
| 40 | - * $callback should be a function of type (string $mountPoint, Storage $storage) => Storage |
|
| 41 | - * |
|
| 42 | - * @param string $wrapperName name of the wrapper |
|
| 43 | - * @param callable $callback callback |
|
| 44 | - * @param int $priority wrappers with the lower priority are applied last (meaning they get called first) |
|
| 45 | - * @param \OCP\Files\Mount\IMountPoint[] $existingMounts existing mount points to apply the wrapper to |
|
| 46 | - * @return bool true if the wrapper was added, false if there was already a wrapper with this |
|
| 47 | - * name registered |
|
| 48 | - */ |
|
| 49 | - public function addStorageWrapper($wrapperName, $callback, $priority = 50, $existingMounts = []) { |
|
| 50 | - if (isset($this->storageWrappers[$wrapperName])) { |
|
| 51 | - return false; |
|
| 52 | - } |
|
| 37 | + /** |
|
| 38 | + * allow modifier storage behaviour by adding wrappers around storages |
|
| 39 | + * |
|
| 40 | + * $callback should be a function of type (string $mountPoint, Storage $storage) => Storage |
|
| 41 | + * |
|
| 42 | + * @param string $wrapperName name of the wrapper |
|
| 43 | + * @param callable $callback callback |
|
| 44 | + * @param int $priority wrappers with the lower priority are applied last (meaning they get called first) |
|
| 45 | + * @param \OCP\Files\Mount\IMountPoint[] $existingMounts existing mount points to apply the wrapper to |
|
| 46 | + * @return bool true if the wrapper was added, false if there was already a wrapper with this |
|
| 47 | + * name registered |
|
| 48 | + */ |
|
| 49 | + public function addStorageWrapper($wrapperName, $callback, $priority = 50, $existingMounts = []) { |
|
| 50 | + if (isset($this->storageWrappers[$wrapperName])) { |
|
| 51 | + return false; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - // apply to existing mounts before registering it to prevent applying it double in MountPoint::createStorage |
|
| 55 | - foreach ($existingMounts as $mount) { |
|
| 56 | - $mount->wrapStorage($callback); |
|
| 57 | - } |
|
| 54 | + // apply to existing mounts before registering it to prevent applying it double in MountPoint::createStorage |
|
| 55 | + foreach ($existingMounts as $mount) { |
|
| 56 | + $mount->wrapStorage($callback); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - $this->storageWrappers[$wrapperName] = ['wrapper' => $callback, 'priority' => $priority]; |
|
| 60 | - return true; |
|
| 61 | - } |
|
| 59 | + $this->storageWrappers[$wrapperName] = ['wrapper' => $callback, 'priority' => $priority]; |
|
| 60 | + return true; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Remove a storage wrapper by name. |
|
| 65 | - * Note: internal method only to be used for cleanup |
|
| 66 | - * |
|
| 67 | - * @param string $wrapperName name of the wrapper |
|
| 68 | - * @internal |
|
| 69 | - */ |
|
| 70 | - public function removeStorageWrapper($wrapperName) { |
|
| 71 | - unset($this->storageWrappers[$wrapperName]); |
|
| 72 | - } |
|
| 63 | + /** |
|
| 64 | + * Remove a storage wrapper by name. |
|
| 65 | + * Note: internal method only to be used for cleanup |
|
| 66 | + * |
|
| 67 | + * @param string $wrapperName name of the wrapper |
|
| 68 | + * @internal |
|
| 69 | + */ |
|
| 70 | + public function removeStorageWrapper($wrapperName) { |
|
| 71 | + unset($this->storageWrappers[$wrapperName]); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * Create an instance of a storage and apply the registered storage wrappers |
|
| 76 | - * |
|
| 77 | - * @param \OCP\Files\Mount\IMountPoint $mountPoint |
|
| 78 | - * @param string $class |
|
| 79 | - * @param array $arguments |
|
| 80 | - * @return \OCP\Files\Storage |
|
| 81 | - */ |
|
| 82 | - public function getInstance(IMountPoint $mountPoint, $class, $arguments) { |
|
| 83 | - return $this->wrap($mountPoint, new $class($arguments)); |
|
| 84 | - } |
|
| 74 | + /** |
|
| 75 | + * Create an instance of a storage and apply the registered storage wrappers |
|
| 76 | + * |
|
| 77 | + * @param \OCP\Files\Mount\IMountPoint $mountPoint |
|
| 78 | + * @param string $class |
|
| 79 | + * @param array $arguments |
|
| 80 | + * @return \OCP\Files\Storage |
|
| 81 | + */ |
|
| 82 | + public function getInstance(IMountPoint $mountPoint, $class, $arguments) { |
|
| 83 | + return $this->wrap($mountPoint, new $class($arguments)); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * @param \OCP\Files\Mount\IMountPoint $mountPoint |
|
| 88 | - * @param \OCP\Files\Storage $storage |
|
| 89 | - * @return \OCP\Files\Storage |
|
| 90 | - */ |
|
| 91 | - public function wrap(IMountPoint $mountPoint, $storage) { |
|
| 92 | - $wrappers = array_values($this->storageWrappers); |
|
| 93 | - usort($wrappers, function ($a, $b) { |
|
| 94 | - return $b['priority'] - $a['priority']; |
|
| 95 | - }); |
|
| 96 | - /** @var callable[] $wrappers */ |
|
| 97 | - $wrappers = array_map(function ($wrapper) { |
|
| 98 | - return $wrapper['wrapper']; |
|
| 99 | - }, $wrappers); |
|
| 100 | - foreach ($wrappers as $wrapper) { |
|
| 101 | - $storage = $wrapper($mountPoint->getMountPoint(), $storage, $mountPoint); |
|
| 102 | - if (!($storage instanceof \OCP\Files\Storage)) { |
|
| 103 | - throw new \Exception('Invalid result from storage wrapper'); |
|
| 104 | - } |
|
| 105 | - } |
|
| 106 | - return $storage; |
|
| 107 | - } |
|
| 86 | + /** |
|
| 87 | + * @param \OCP\Files\Mount\IMountPoint $mountPoint |
|
| 88 | + * @param \OCP\Files\Storage $storage |
|
| 89 | + * @return \OCP\Files\Storage |
|
| 90 | + */ |
|
| 91 | + public function wrap(IMountPoint $mountPoint, $storage) { |
|
| 92 | + $wrappers = array_values($this->storageWrappers); |
|
| 93 | + usort($wrappers, function ($a, $b) { |
|
| 94 | + return $b['priority'] - $a['priority']; |
|
| 95 | + }); |
|
| 96 | + /** @var callable[] $wrappers */ |
|
| 97 | + $wrappers = array_map(function ($wrapper) { |
|
| 98 | + return $wrapper['wrapper']; |
|
| 99 | + }, $wrappers); |
|
| 100 | + foreach ($wrappers as $wrapper) { |
|
| 101 | + $storage = $wrapper($mountPoint->getMountPoint(), $storage, $mountPoint); |
|
| 102 | + if (!($storage instanceof \OCP\Files\Storage)) { |
|
| 103 | + throw new \Exception('Invalid result from storage wrapper'); |
|
| 104 | + } |
|
| 105 | + } |
|
| 106 | + return $storage; |
|
| 107 | + } |
|
| 108 | 108 | } |
@@ -90,11 +90,11 @@ |
||
| 90 | 90 | */ |
| 91 | 91 | public function wrap(IMountPoint $mountPoint, $storage) { |
| 92 | 92 | $wrappers = array_values($this->storageWrappers); |
| 93 | - usort($wrappers, function ($a, $b) { |
|
| 93 | + usort($wrappers, function($a, $b) { |
|
| 94 | 94 | return $b['priority'] - $a['priority']; |
| 95 | 95 | }); |
| 96 | 96 | /** @var callable[] $wrappers */ |
| 97 | - $wrappers = array_map(function ($wrapper) { |
|
| 97 | + $wrappers = array_map(function($wrapper) { |
|
| 98 | 98 | return $wrapper['wrapper']; |
| 99 | 99 | }, $wrappers); |
| 100 | 100 | foreach ($wrappers as $wrapper) { |
@@ -89,11 +89,11 @@ |
||
| 89 | 89 | $result = true; |
| 90 | 90 | while ($file = readdir($dh)) { |
| 91 | 91 | if (!\OC\Files\Filesystem::isIgnoredDir($file)) { |
| 92 | - if ($this->is_dir($source . '/' . $file)) { |
|
| 93 | - $this->mkdir($target . '/' . $file); |
|
| 94 | - $result = $this->copyRecursive($source . '/' . $file, $target . '/' . $file); |
|
| 92 | + if ($this->is_dir($source.'/'.$file)) { |
|
| 93 | + $this->mkdir($target.'/'.$file); |
|
| 94 | + $result = $this->copyRecursive($source.'/'.$file, $target.'/'.$file); |
|
| 95 | 95 | } else { |
| 96 | - $result = parent::copy($source . '/' . $file, $target . '/' . $file); |
|
| 96 | + $result = parent::copy($source.'/'.$file, $target.'/'.$file); |
|
| 97 | 97 | } |
| 98 | 98 | if (!$result) { |
| 99 | 99 | break; |
@@ -24,81 +24,81 @@ |
||
| 24 | 24 | namespace OC\Files\Storage\PolyFill; |
| 25 | 25 | |
| 26 | 26 | trait CopyDirectory { |
| 27 | - /** |
|
| 28 | - * Check if a path is a directory |
|
| 29 | - * |
|
| 30 | - * @param string $path |
|
| 31 | - * @return bool |
|
| 32 | - */ |
|
| 33 | - abstract public function is_dir($path); |
|
| 27 | + /** |
|
| 28 | + * Check if a path is a directory |
|
| 29 | + * |
|
| 30 | + * @param string $path |
|
| 31 | + * @return bool |
|
| 32 | + */ |
|
| 33 | + abstract public function is_dir($path); |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Check if a file or folder exists |
|
| 37 | - * |
|
| 38 | - * @param string $path |
|
| 39 | - * @return bool |
|
| 40 | - */ |
|
| 41 | - abstract public function file_exists($path); |
|
| 35 | + /** |
|
| 36 | + * Check if a file or folder exists |
|
| 37 | + * |
|
| 38 | + * @param string $path |
|
| 39 | + * @return bool |
|
| 40 | + */ |
|
| 41 | + abstract public function file_exists($path); |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Delete a file or folder |
|
| 45 | - * |
|
| 46 | - * @param string $path |
|
| 47 | - * @return bool |
|
| 48 | - */ |
|
| 49 | - abstract public function unlink($path); |
|
| 43 | + /** |
|
| 44 | + * Delete a file or folder |
|
| 45 | + * |
|
| 46 | + * @param string $path |
|
| 47 | + * @return bool |
|
| 48 | + */ |
|
| 49 | + abstract public function unlink($path); |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Open a directory handle for a folder |
|
| 53 | - * |
|
| 54 | - * @param string $path |
|
| 55 | - * @return resource | bool |
|
| 56 | - */ |
|
| 57 | - abstract public function opendir($path); |
|
| 51 | + /** |
|
| 52 | + * Open a directory handle for a folder |
|
| 53 | + * |
|
| 54 | + * @param string $path |
|
| 55 | + * @return resource | bool |
|
| 56 | + */ |
|
| 57 | + abstract public function opendir($path); |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * Create a new folder |
|
| 61 | - * |
|
| 62 | - * @param string $path |
|
| 63 | - * @return bool |
|
| 64 | - */ |
|
| 65 | - abstract public function mkdir($path); |
|
| 59 | + /** |
|
| 60 | + * Create a new folder |
|
| 61 | + * |
|
| 62 | + * @param string $path |
|
| 63 | + * @return bool |
|
| 64 | + */ |
|
| 65 | + abstract public function mkdir($path); |
|
| 66 | 66 | |
| 67 | - public function copy($path1, $path2) { |
|
| 68 | - if ($this->is_dir($path1)) { |
|
| 69 | - if ($this->file_exists($path2)) { |
|
| 70 | - $this->unlink($path2); |
|
| 71 | - } |
|
| 72 | - $this->mkdir($path2); |
|
| 73 | - return $this->copyRecursive($path1, $path2); |
|
| 74 | - } else { |
|
| 75 | - return parent::copy($path1, $path2); |
|
| 76 | - } |
|
| 77 | - } |
|
| 67 | + public function copy($path1, $path2) { |
|
| 68 | + if ($this->is_dir($path1)) { |
|
| 69 | + if ($this->file_exists($path2)) { |
|
| 70 | + $this->unlink($path2); |
|
| 71 | + } |
|
| 72 | + $this->mkdir($path2); |
|
| 73 | + return $this->copyRecursive($path1, $path2); |
|
| 74 | + } else { |
|
| 75 | + return parent::copy($path1, $path2); |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * For adapters that don't support copying folders natively |
|
| 81 | - * |
|
| 82 | - * @param $source |
|
| 83 | - * @param $target |
|
| 84 | - * @return bool |
|
| 85 | - */ |
|
| 86 | - protected function copyRecursive($source, $target) { |
|
| 87 | - $dh = $this->opendir($source); |
|
| 88 | - $result = true; |
|
| 89 | - while ($file = readdir($dh)) { |
|
| 90 | - if (!\OC\Files\Filesystem::isIgnoredDir($file)) { |
|
| 91 | - if ($this->is_dir($source . '/' . $file)) { |
|
| 92 | - $this->mkdir($target . '/' . $file); |
|
| 93 | - $result = $this->copyRecursive($source . '/' . $file, $target . '/' . $file); |
|
| 94 | - } else { |
|
| 95 | - $result = parent::copy($source . '/' . $file, $target . '/' . $file); |
|
| 96 | - } |
|
| 97 | - if (!$result) { |
|
| 98 | - break; |
|
| 99 | - } |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | - return $result; |
|
| 103 | - } |
|
| 79 | + /** |
|
| 80 | + * For adapters that don't support copying folders natively |
|
| 81 | + * |
|
| 82 | + * @param $source |
|
| 83 | + * @param $target |
|
| 84 | + * @return bool |
|
| 85 | + */ |
|
| 86 | + protected function copyRecursive($source, $target) { |
|
| 87 | + $dh = $this->opendir($source); |
|
| 88 | + $result = true; |
|
| 89 | + while ($file = readdir($dh)) { |
|
| 90 | + if (!\OC\Files\Filesystem::isIgnoredDir($file)) { |
|
| 91 | + if ($this->is_dir($source . '/' . $file)) { |
|
| 92 | + $this->mkdir($target . '/' . $file); |
|
| 93 | + $result = $this->copyRecursive($source . '/' . $file, $target . '/' . $file); |
|
| 94 | + } else { |
|
| 95 | + $result = parent::copy($source . '/' . $file, $target . '/' . $file); |
|
| 96 | + } |
|
| 97 | + if (!$result) { |
|
| 98 | + break; |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | + } |
|
| 102 | + return $result; |
|
| 103 | + } |
|
| 104 | 104 | } |
@@ -26,27 +26,27 @@ |
||
| 26 | 26 | use OCP\Files\Notify\IRenameChange; |
| 27 | 27 | |
| 28 | 28 | class RenameChange extends Change implements IRenameChange { |
| 29 | - /** @var string */ |
|
| 30 | - private $targetPath; |
|
| 29 | + /** @var string */ |
|
| 30 | + private $targetPath; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Change constructor. |
|
| 34 | - * |
|
| 35 | - * @param int $type |
|
| 36 | - * @param string $path |
|
| 37 | - * @param string $targetPath |
|
| 38 | - */ |
|
| 39 | - public function __construct($type, $path, $targetPath) { |
|
| 40 | - parent::__construct($type, $path); |
|
| 41 | - $this->targetPath = $targetPath; |
|
| 42 | - } |
|
| 32 | + /** |
|
| 33 | + * Change constructor. |
|
| 34 | + * |
|
| 35 | + * @param int $type |
|
| 36 | + * @param string $path |
|
| 37 | + * @param string $targetPath |
|
| 38 | + */ |
|
| 39 | + public function __construct($type, $path, $targetPath) { |
|
| 40 | + parent::__construct($type, $path); |
|
| 41 | + $this->targetPath = $targetPath; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Get the new path of the renamed file relative to the storage root |
|
| 46 | - * |
|
| 47 | - * @return string |
|
| 48 | - */ |
|
| 49 | - public function getTargetPath() { |
|
| 50 | - return $this->targetPath; |
|
| 51 | - } |
|
| 44 | + /** |
|
| 45 | + * Get the new path of the renamed file relative to the storage root |
|
| 46 | + * |
|
| 47 | + * @return string |
|
| 48 | + */ |
|
| 49 | + public function getTargetPath() { |
|
| 50 | + return $this->targetPath; |
|
| 51 | + } |
|
| 52 | 52 | } |
@@ -26,40 +26,40 @@ |
||
| 26 | 26 | use OCP\Files\Notify\IChange; |
| 27 | 27 | |
| 28 | 28 | class Change implements IChange { |
| 29 | - /** @var int */ |
|
| 30 | - private $type; |
|
| 29 | + /** @var int */ |
|
| 30 | + private $type; |
|
| 31 | 31 | |
| 32 | - /** @var string */ |
|
| 33 | - private $path; |
|
| 32 | + /** @var string */ |
|
| 33 | + private $path; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Change constructor. |
|
| 37 | - * |
|
| 38 | - * @param int $type |
|
| 39 | - * @param string $path |
|
| 40 | - */ |
|
| 41 | - public function __construct($type, $path) { |
|
| 42 | - $this->type = $type; |
|
| 43 | - $this->path = $path; |
|
| 44 | - } |
|
| 35 | + /** |
|
| 36 | + * Change constructor. |
|
| 37 | + * |
|
| 38 | + * @param int $type |
|
| 39 | + * @param string $path |
|
| 40 | + */ |
|
| 41 | + public function __construct($type, $path) { |
|
| 42 | + $this->type = $type; |
|
| 43 | + $this->path = $path; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Get the type of the change |
|
| 48 | - * |
|
| 49 | - * @return int IChange::ADDED, IChange::REMOVED, IChange::MODIFIED or IChange::RENAMED |
|
| 50 | - */ |
|
| 51 | - public function getType() { |
|
| 52 | - return $this->type; |
|
| 53 | - } |
|
| 46 | + /** |
|
| 47 | + * Get the type of the change |
|
| 48 | + * |
|
| 49 | + * @return int IChange::ADDED, IChange::REMOVED, IChange::MODIFIED or IChange::RENAMED |
|
| 50 | + */ |
|
| 51 | + public function getType() { |
|
| 52 | + return $this->type; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Get the path of the file that was changed relative to the root of the storage |
|
| 57 | - * |
|
| 58 | - * Note, for rename changes this path is the old path for the file |
|
| 59 | - * |
|
| 60 | - * @return mixed |
|
| 61 | - */ |
|
| 62 | - public function getPath() { |
|
| 63 | - return $this->path; |
|
| 64 | - } |
|
| 55 | + /** |
|
| 56 | + * Get the path of the file that was changed relative to the root of the storage |
|
| 57 | + * |
|
| 58 | + * Note, for rename changes this path is the old path for the file |
|
| 59 | + * |
|
| 60 | + * @return mixed |
|
| 61 | + */ |
|
| 62 | + public function getPath() { |
|
| 63 | + return $this->path; |
|
| 64 | + } |
|
| 65 | 65 | } |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | * @package OC\AppFramework\Middleware\Security\Exceptions |
| 32 | 32 | */ |
| 33 | 33 | class NotConfirmedException extends SecurityException { |
| 34 | - public function __construct() { |
|
| 35 | - parent::__construct('Password confirmation is required', Http::STATUS_FORBIDDEN); |
|
| 36 | - } |
|
| 34 | + public function __construct() { |
|
| 35 | + parent::__construct('Password confirmation is required', Http::STATUS_FORBIDDEN); |
|
| 36 | + } |
|
| 37 | 37 | } |
@@ -34,7 +34,7 @@ |
||
| 34 | 34 | * @package OC\AppFramework\Middleware\Security\Exceptions |
| 35 | 35 | */ |
| 36 | 36 | class CrossSiteRequestForgeryException extends SecurityException { |
| 37 | - public function __construct() { |
|
| 38 | - parent::__construct('CSRF check failed', Http::STATUS_PRECONDITION_FAILED); |
|
| 39 | - } |
|
| 37 | + public function __construct() { |
|
| 38 | + parent::__construct('CSRF check failed', Http::STATUS_PRECONDITION_FAILED); |
|
| 39 | + } |
|
| 40 | 40 | } |
@@ -34,7 +34,7 @@ |
||
| 34 | 34 | * @package OC\AppFramework\Middleware\Security\Exceptions |
| 35 | 35 | */ |
| 36 | 36 | class AppNotEnabledException extends SecurityException { |
| 37 | - public function __construct() { |
|
| 38 | - parent::__construct('App is not enabled', Http::STATUS_PRECONDITION_FAILED); |
|
| 39 | - } |
|
| 37 | + public function __construct() { |
|
| 38 | + parent::__construct('App is not enabled', Http::STATUS_PRECONDITION_FAILED); |
|
| 39 | + } |
|
| 40 | 40 | } |