Completed
Push — master ( d34320...71c2e9 )
by
unknown
27:32
created
apps/dav/lib/Connector/Sabre/FilesPlugin.php 1 patch
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -140,9 +140,9 @@  discard block
 block discarded – undo
140 140
 		$this->server->on('propPatch', [$this, 'handleUpdateProperties']);
141 141
 		$this->server->on('afterBind', [$this, 'sendFileIdHeader']);
142 142
 		$this->server->on('afterWriteContent', [$this, 'sendFileIdHeader']);
143
-		$this->server->on('afterMethod:GET', [$this,'httpGet']);
143
+		$this->server->on('afterMethod:GET', [$this, 'httpGet']);
144 144
 		$this->server->on('afterMethod:GET', [$this, 'handleDownloadToken']);
145
-		$this->server->on('afterResponse', function ($request, ResponseInterface $response): void {
145
+		$this->server->on('afterResponse', function($request, ResponseInterface $response): void {
146 146
 			$body = $response->getBody();
147 147
 			if (is_resource($body)) {
148 148
 				fclose($body);
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 		// Ensure source exists
170 170
 		$sourceNodeFileInfo = $sourceNode->getFileInfo();
171 171
 		if ($sourceNodeFileInfo === null) {
172
-			throw new NotFound($source . ' does not exist');
172
+			throw new NotFound($source.' does not exist');
173 173
 		}
174 174
 		// Ensure the target name is valid
175 175
 		try {
@@ -209,12 +209,12 @@  discard block
 block discarded – undo
209 209
 		// The source needs to be deletable for moving
210 210
 		$sourceNodeFileInfo = $sourceNode->getFileInfo();
211 211
 		if (!$sourceNodeFileInfo->isDeletable()) {
212
-			throw new Forbidden($source . ' cannot be deleted');
212
+			throw new Forbidden($source.' cannot be deleted');
213 213
 		}
214 214
 
215 215
 		// The source is not allowed to be the parent of the target
216
-		if (str_starts_with($source, $target . '/')) {
217
-			throw new Forbidden($source . ' cannot be moved to it\'s parent');
216
+		if (str_starts_with($source, $target.'/')) {
217
+			throw new Forbidden($source.' cannot be moved to it\'s parent');
218 218
 		}
219 219
 	}
220 220
 
@@ -268,10 +268,10 @@  discard block
 block discarded – undo
268 268
 					Request::USER_AGENT_ANDROID_MOBILE_CHROME,
269 269
 					Request::USER_AGENT_FREEBOX,
270 270
 				])) {
271
-				$response->addHeader('Content-Disposition', 'attachment; filename="' . rawurlencode($filename) . '"');
271
+				$response->addHeader('Content-Disposition', 'attachment; filename="'.rawurlencode($filename).'"');
272 272
 			} else {
273
-				$response->addHeader('Content-Disposition', 'attachment; filename*=UTF-8\'\'' . rawurlencode($filename)
274
-													 . '; filename="' . rawurlencode($filename) . '"');
273
+				$response->addHeader('Content-Disposition', 'attachment; filename*=UTF-8\'\''.rawurlencode($filename)
274
+													 . '; filename="'.rawurlencode($filename).'"');
275 275
 			}
276 276
 		}
277 277
 
@@ -307,15 +307,15 @@  discard block
 block discarded – undo
307 307
 			 * }
308 308
 			 */
309 309
 
310
-			$propFind->handle(self::FILEID_PROPERTYNAME, function () use ($node) {
310
+			$propFind->handle(self::FILEID_PROPERTYNAME, function() use ($node) {
311 311
 				return $node->getFileId();
312 312
 			});
313 313
 
314
-			$propFind->handle(self::INTERNAL_FILEID_PROPERTYNAME, function () use ($node) {
314
+			$propFind->handle(self::INTERNAL_FILEID_PROPERTYNAME, function() use ($node) {
315 315
 				return $node->getInternalFileId();
316 316
 			});
317 317
 
318
-			$propFind->handle(self::PERMISSIONS_PROPERTYNAME, function () use ($node) {
318
+			$propFind->handle(self::PERMISSIONS_PROPERTYNAME, function() use ($node) {
319 319
 				$perms = $node->getDavPermissions();
320 320
 				if ($this->isPublic) {
321 321
 					// remove mount information
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 				return $perms;
325 325
 			});
326 326
 
327
-			$propFind->handle(self::SHARE_PERMISSIONS_PROPERTYNAME, function () use ($node, $httpRequest) {
327
+			$propFind->handle(self::SHARE_PERMISSIONS_PROPERTYNAME, function() use ($node, $httpRequest) {
328 328
 				$user = $this->userSession->getUser();
329 329
 				if ($user === null) {
330 330
 					return null;
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 				);
335 335
 			});
336 336
 
337
-			$propFind->handle(self::OCM_SHARE_PERMISSIONS_PROPERTYNAME, function () use ($node, $httpRequest): ?string {
337
+			$propFind->handle(self::OCM_SHARE_PERMISSIONS_PROPERTYNAME, function() use ($node, $httpRequest): ?string {
338 338
 				$user = $this->userSession->getUser();
339 339
 				if ($user === null) {
340 340
 					return null;
@@ -346,15 +346,15 @@  discard block
 block discarded – undo
346 346
 				return json_encode($ocmPermissions, JSON_THROW_ON_ERROR);
347 347
 			});
348 348
 
349
-			$propFind->handle(self::SHARE_ATTRIBUTES_PROPERTYNAME, function () use ($node, $httpRequest) {
349
+			$propFind->handle(self::SHARE_ATTRIBUTES_PROPERTYNAME, function() use ($node, $httpRequest) {
350 350
 				return json_encode($node->getShareAttributes(), JSON_THROW_ON_ERROR);
351 351
 			});
352 352
 
353
-			$propFind->handle(self::GETETAG_PROPERTYNAME, function () use ($node): string {
353
+			$propFind->handle(self::GETETAG_PROPERTYNAME, function() use ($node): string {
354 354
 				return $node->getETag();
355 355
 			});
356 356
 
357
-			$propFind->handle(self::OWNER_ID_PROPERTYNAME, function () use ($node): ?string {
357
+			$propFind->handle(self::OWNER_ID_PROPERTYNAME, function() use ($node): ?string {
358 358
 				$owner = $node->getOwner();
359 359
 				if (!$owner) {
360 360
 					return null;
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
 					return $owner->getUID();
363 363
 				}
364 364
 			});
365
-			$propFind->handle(self::OWNER_DISPLAY_NAME_PROPERTYNAME, function () use ($node): ?string {
365
+			$propFind->handle(self::OWNER_DISPLAY_NAME_PROPERTYNAME, function() use ($node): ?string {
366 366
 				$owner = $node->getOwner();
367 367
 				if (!$owner) {
368 368
 					return null;
@@ -394,13 +394,13 @@  discard block
 block discarded – undo
394 394
 				return null;
395 395
 			});
396 396
 
397
-			$propFind->handle(self::HAS_PREVIEW_PROPERTYNAME, function () use ($node) {
397
+			$propFind->handle(self::HAS_PREVIEW_PROPERTYNAME, function() use ($node) {
398 398
 				return json_encode($this->previewManager->isAvailable($node->getFileInfo()), JSON_THROW_ON_ERROR);
399 399
 			});
400
-			$propFind->handle(self::SIZE_PROPERTYNAME, function () use ($node): int|float {
400
+			$propFind->handle(self::SIZE_PROPERTYNAME, function() use ($node): int | float {
401 401
 				return $node->getSize();
402 402
 			});
403
-			$propFind->handle(self::MOUNT_TYPE_PROPERTYNAME, function () use ($node) {
403
+			$propFind->handle(self::MOUNT_TYPE_PROPERTYNAME, function() use ($node) {
404 404
 				return $node->getFileInfo()->getMountPoint()->getMountType();
405 405
 			});
406 406
 
@@ -410,18 +410,18 @@  discard block
 block discarded – undo
410 410
 			 * If so, then the node can only be unshared and not deleted.
411 411
 			 * @see https://github.com/nextcloud/server/blob/cc75294eb6b16b916a342e69998935f89222619d/lib/private/Files/View.php#L696-L698
412 412
 			 */
413
-			$propFind->handle(self::MOUNT_ROOT_PROPERTYNAME, function () use ($node) {
413
+			$propFind->handle(self::MOUNT_ROOT_PROPERTYNAME, function() use ($node) {
414 414
 				return $node->getNode()->getInternalPath() === '' ? 'true' : 'false';
415 415
 			});
416 416
 
417
-			$propFind->handle(self::SHARE_NOTE, function () use ($node): ?string {
417
+			$propFind->handle(self::SHARE_NOTE, function() use ($node): ?string {
418 418
 				$user = $this->userSession->getUser();
419 419
 				return $node->getNoteFromShare(
420 420
 					$user?->getUID()
421 421
 				);
422 422
 			});
423 423
 
424
-			$propFind->handle(self::SHARE_HIDE_DOWNLOAD_PROPERTYNAME, function () use ($node) {
424
+			$propFind->handle(self::SHARE_HIDE_DOWNLOAD_PROPERTYNAME, function() use ($node) {
425 425
 				$storage = $node->getNode()->getStorage();
426 426
 				if ($storage->instanceOfStorage(ISharedStorage::class)) {
427 427
 					/** @var ISharedStorage $storage */
@@ -434,23 +434,23 @@  discard block
 block discarded – undo
434 434
 				}
435 435
 			});
436 436
 
437
-			$propFind->handle(self::DATA_FINGERPRINT_PROPERTYNAME, function () {
437
+			$propFind->handle(self::DATA_FINGERPRINT_PROPERTYNAME, function() {
438 438
 				return $this->config->getSystemValue('data-fingerprint', '');
439 439
 			});
440
-			$propFind->handle(self::CREATIONDATE_PROPERTYNAME, function () use ($node) {
440
+			$propFind->handle(self::CREATIONDATE_PROPERTYNAME, function() use ($node) {
441 441
 				return (new \DateTimeImmutable())
442 442
 					->setTimestamp($node->getFileInfo()->getCreationTime())
443 443
 					->format(\DateTimeInterface::ATOM);
444 444
 			});
445
-			$propFind->handle(self::CREATION_TIME_PROPERTYNAME, function () use ($node) {
445
+			$propFind->handle(self::CREATION_TIME_PROPERTYNAME, function() use ($node) {
446 446
 				return $node->getFileInfo()->getCreationTime();
447 447
 			});
448 448
 
449 449
 			foreach ($node->getFileInfo()->getMetadata() as $metadataKey => $metadataValue) {
450
-				$propFind->handle(self::FILE_METADATA_PREFIX . $metadataKey, $metadataValue);
450
+				$propFind->handle(self::FILE_METADATA_PREFIX.$metadataKey, $metadataValue);
451 451
 			}
452 452
 
453
-			$propFind->handle(self::HIDDEN_PROPERTYNAME, function () use ($node) {
453
+			$propFind->handle(self::HIDDEN_PROPERTYNAME, function() use ($node) {
454 454
 				$isLivePhoto = isset($node->getFileInfo()->getMetadata()['files-live-photo']);
455 455
 				$isMovFile = $node->getFileInfo()->getMimetype() === 'video/quicktime';
456 456
 				return ($isLivePhoto && $isMovFile) ? 'true' : 'false';
@@ -462,11 +462,11 @@  discard block
 block discarded – undo
462 462
 			 * CustomPropertiesBackend (esp. visible when querying all files
463 463
 			 * in a folder).
464 464
 			 */
465
-			$propFind->handle(self::DISPLAYNAME_PROPERTYNAME, function () use ($node) {
465
+			$propFind->handle(self::DISPLAYNAME_PROPERTYNAME, function() use ($node) {
466 466
 				return $node->getName();
467 467
 			});
468 468
 
469
-			$propFind->handle(self::IS_FEDERATED_PROPERTYNAME, function () use ($node) {
469
+			$propFind->handle(self::IS_FEDERATED_PROPERTYNAME, function() use ($node) {
470 470
 				return $node->getFileInfo()->getMountPoint()
471 471
 					instanceof SharingExternalMount;
472 472
 			});
@@ -479,18 +479,18 @@  discard block
 block discarded – undo
479 479
 				|| in_array(self::DOWNLOADURL_EXPIRATION_PROPERTYNAME, $requestProperties, true)) {
480 480
 				try {
481 481
 					$directDownloadUrl = $node->getDirectDownload();
482
-				} catch (StorageNotAvailableException|ForbiddenException) {
482
+				} catch (StorageNotAvailableException | ForbiddenException) {
483 483
 					$directDownloadUrl = null;
484 484
 				}
485 485
 
486
-				$propFind->handle(self::DOWNLOADURL_PROPERTYNAME, function () use ($node, $directDownloadUrl) {
486
+				$propFind->handle(self::DOWNLOADURL_PROPERTYNAME, function() use ($node, $directDownloadUrl) {
487 487
 					if ($directDownloadUrl && isset($directDownloadUrl['url'])) {
488 488
 						return $directDownloadUrl['url'];
489 489
 					}
490 490
 					return false;
491 491
 				});
492 492
 
493
-				$propFind->handle(self::DOWNLOADURL_EXPIRATION_PROPERTYNAME, function () use ($node, $directDownloadUrl) {
493
+				$propFind->handle(self::DOWNLOADURL_EXPIRATION_PROPERTYNAME, function() use ($node, $directDownloadUrl) {
494 494
 					if ($directDownloadUrl && isset($directDownloadUrl['expiration'])) {
495 495
 						return $directDownloadUrl['expiration'];
496 496
 					}
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
 				});
499 499
 			}
500 500
 
501
-			$propFind->handle(self::CHECKSUMS_PROPERTYNAME, function () use ($node) {
501
+			$propFind->handle(self::CHECKSUMS_PROPERTYNAME, function() use ($node) {
502 502
 				$checksum = $node->getChecksum();
503 503
 				if ($checksum === null || $checksum === '') {
504 504
 					return null;
@@ -507,13 +507,13 @@  discard block
 block discarded – undo
507 507
 				return new ChecksumList($checksum);
508 508
 			});
509 509
 
510
-			$propFind->handle(self::UPLOAD_TIME_PROPERTYNAME, function () use ($node) {
510
+			$propFind->handle(self::UPLOAD_TIME_PROPERTYNAME, function() use ($node) {
511 511
 				return $node->getFileInfo()->getUploadTime();
512 512
 			});
513 513
 		}
514 514
 
515 515
 		if ($node instanceof Directory) {
516
-			$propFind->handle(self::SIZE_PROPERTYNAME, function () use ($node) {
516
+			$propFind->handle(self::SIZE_PROPERTYNAME, function() use ($node) {
517 517
 				return $node->getSize();
518 518
 			});
519 519
 
@@ -576,20 +576,20 @@  discard block
 block discarded – undo
576 576
 			return;
577 577
 		}
578 578
 
579
-		$propPatch->handle(self::LASTMODIFIED_PROPERTYNAME, function ($time) use ($node) {
579
+		$propPatch->handle(self::LASTMODIFIED_PROPERTYNAME, function($time) use ($node) {
580 580
 			if (empty($time)) {
581 581
 				return false;
582 582
 			}
583 583
 			$node->touch($time);
584 584
 			return true;
585 585
 		});
586
-		$propPatch->handle(self::GETETAG_PROPERTYNAME, function ($etag) use ($node) {
586
+		$propPatch->handle(self::GETETAG_PROPERTYNAME, function($etag) use ($node) {
587 587
 			if (empty($etag)) {
588 588
 				return false;
589 589
 			}
590 590
 			return $node->setEtag($etag) !== -1;
591 591
 		});
592
-		$propPatch->handle(self::CREATIONDATE_PROPERTYNAME, function ($time) use ($node) {
592
+		$propPatch->handle(self::CREATIONDATE_PROPERTYNAME, function($time) use ($node) {
593 593
 			if (empty($time)) {
594 594
 				return false;
595 595
 			}
@@ -597,11 +597,11 @@  discard block
 block discarded – undo
597 597
 			$node->setCreationTime($dateTime->getTimestamp());
598 598
 			return true;
599 599
 		});
600
-		$propPatch->handle(self::CREATION_TIME_PROPERTYNAME, function ($time) use ($node) {
600
+		$propPatch->handle(self::CREATION_TIME_PROPERTYNAME, function($time) use ($node) {
601 601
 			if (empty($time)) {
602 602
 				return false;
603 603
 			}
604
-			$node->setCreationTime((int)$time);
604
+			$node->setCreationTime((int) $time);
605 605
 			return true;
606 606
 		});
607 607
 
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 		 * Disable modification of the displayname property for files and
612 612
 		 * folders via PROPPATCH. See PROPFIND for more information.
613 613
 		 */
614
-		$propPatch->handle(self::DISPLAYNAME_PROPERTYNAME, function ($displayName) {
614
+		$propPatch->handle(self::DISPLAYNAME_PROPERTYNAME, function($displayName) {
615 615
 			return 403;
616 616
 		});
617 617
 	}
@@ -642,15 +642,15 @@  discard block
 block discarded – undo
642 642
 
643 643
 			$propPatch->handle(
644 644
 				$mutation,
645
-				function (mixed $value) use ($accessRight, $knownMetadata, $node, $mutation, $filesMetadataManager): bool {
645
+				function(mixed $value) use ($accessRight, $knownMetadata, $node, $mutation, $filesMetadataManager): bool {
646 646
 					/** @var FilesMetadata $metadata */
647
-					$metadata = $filesMetadataManager->getMetadata((int)$node->getFileId(), true);
647
+					$metadata = $filesMetadataManager->getMetadata((int) $node->getFileId(), true);
648 648
 					$metadata->setStorageId($node->getNode()->getStorage()->getCache()->getNumericStorageId());
649 649
 					$metadataKey = substr($mutation, strlen(self::FILE_METADATA_PREFIX));
650 650
 
651 651
 					// confirm metadata key is editable via PROPPATCH
652 652
 					if ($knownMetadata->getEditPermission($metadataKey) < $accessRight) {
653
-						throw new FilesMetadataException('you do not have enough rights to update \'' . $metadataKey . '\' on this node');
653
+						throw new FilesMetadataException('you do not have enough rights to update \''.$metadataKey.'\' on this node');
654 654
 					}
655 655
 
656 656
 					if ($value === null) {
Please login to merge, or discard this patch.