Passed
Push — master ( aaa226...2be74e )
by Blizzz
16:51 queued 14s
created
apps/files_trashbin/lib/Trashbin.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 		Filesystem::initMountPoints($uid);
107 107
 		if ($uid !== OC_User::getUser()) {
108 108
 			$info = Filesystem::getFileInfo($filename);
109
-			$ownerView = new View('/' . $uid . '/files');
109
+			$ownerView = new View('/'.$uid.'/files');
110 110
 			try {
111 111
 				$filename = $ownerView->getPath($info['fileid']);
112 112
 			} catch (NotFoundException $e) {
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 	}
169 169
 
170 170
 	private static function setUpTrash($user) {
171
-		$view = new View('/' . $user);
171
+		$view = new View('/'.$user);
172 172
 		if (!$view->is_dir('files_trashbin')) {
173 173
 			$view->mkdir('files_trashbin');
174 174
 		}
@@ -203,8 +203,8 @@  discard block
 block discarded – undo
203 203
 
204 204
 		$view = new View('/');
205 205
 
206
-		$target = $user . '/files_trashbin/files/' . static::getTrashFilename($targetFilename, $timestamp);
207
-		$source = $owner . '/files_trashbin/files/' . static::getTrashFilename($sourceFilename, $timestamp);
206
+		$target = $user.'/files_trashbin/files/'.static::getTrashFilename($targetFilename, $timestamp);
207
+		$source = $owner.'/files_trashbin/files/'.static::getTrashFilename($sourceFilename, $timestamp);
208 208
 		$free = $view->free_space($target);
209 209
 		$isUnknownOrUnlimitedFreeSpace = $free < 0;
210 210
 		$isEnoughFreeSpaceLeft = $view->filesize($source) < $free;
@@ -248,14 +248,14 @@  discard block
 block discarded – undo
248 248
 			$ownerPath = $file_path;
249 249
 		}
250 250
 
251
-		$ownerView = new View('/' . $owner);
251
+		$ownerView = new View('/'.$owner);
252 252
 
253 253
 		// file has been deleted in between
254 254
 		if (is_null($ownerPath) || $ownerPath === '') {
255 255
 			return true;
256 256
 		}
257 257
 
258
-		$sourceInfo = $ownerView->getFileInfo('/files/' . $ownerPath);
258
+		$sourceInfo = $ownerView->getFileInfo('/files/'.$ownerPath);
259 259
 
260 260
 		if ($sourceInfo === false) {
261 261
 			return true;
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 		$lockingProvider = \OC::$server->getLockingProvider();
279 279
 
280 280
 		// disable proxy to prevent recursive calls
281
-		$trashPath = '/files_trashbin/files/' . static::getTrashFilename($filename, $timestamp);
281
+		$trashPath = '/files_trashbin/files/'.static::getTrashFilename($filename, $timestamp);
282 282
 		$gotLock = false;
283 283
 
284 284
 		while (!$gotLock) {
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 
295 295
 				$timestamp = $timestamp + 1;
296 296
 
297
-				$trashPath = '/files_trashbin/files/' . static::getTrashFilename($filename, $timestamp);
297
+				$trashPath = '/files_trashbin/files/'.static::getTrashFilename($filename, $timestamp);
298 298
 			}
299 299
 		}
300 300
 
@@ -306,8 +306,8 @@  discard block
 block discarded – undo
306 306
 		}
307 307
 
308 308
 		$config = \OC::$server->getConfig();
309
-		$systemTrashbinSize = (int)$config->getAppValue('files_trashbin', 'trashbin_size', '-1');
310
-		$userTrashbinSize = (int)$config->getUserValue($owner, 'files_trashbin', 'trashbin_size', '-1');
309
+		$systemTrashbinSize = (int) $config->getAppValue('files_trashbin', 'trashbin_size', '-1');
310
+		$userTrashbinSize = (int) $config->getUserValue($owner, 'files_trashbin', 'trashbin_size', '-1');
311 311
 		$configuredTrashbinSize = ($userTrashbinSize < 0) ? $systemTrashbinSize : $userTrashbinSize;
312 312
 		if ($configuredTrashbinSize >= 0 && $sourceInfo->getSize() >= $configuredTrashbinSize) {
313 313
 			return false;
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 			if ($trashStorage->file_exists($trashInternalPath)) {
328 328
 				$trashStorage->unlink($trashInternalPath);
329 329
 			}
330
-			\OC::$server->get(LoggerInterface::class)->error('Couldn\'t move ' . $file_path . ' to the trash bin', ['app' => 'files_trashbin']);
330
+			\OC::$server->get(LoggerInterface::class)->error('Couldn\'t move '.$file_path.' to the trash bin', ['app' => 'files_trashbin']);
331 331
 		}
332 332
 
333 333
 		if ($sourceStorage->file_exists($sourceInternalPath)) { // failed to delete the original file, abort
@@ -393,17 +393,17 @@  discard block
 block discarded – undo
393 393
 			$user = OC_User::getUser();
394 394
 			$rootView = new View('/');
395 395
 
396
-			if ($rootView->is_dir($owner . '/files_versions/' . $ownerPath)) {
396
+			if ($rootView->is_dir($owner.'/files_versions/'.$ownerPath)) {
397 397
 				if ($owner !== $user) {
398
-					self::copy_recursive($owner . '/files_versions/' . $ownerPath, $owner . '/files_trashbin/versions/' . static::getTrashFilename(basename($ownerPath), $timestamp), $rootView);
398
+					self::copy_recursive($owner.'/files_versions/'.$ownerPath, $owner.'/files_trashbin/versions/'.static::getTrashFilename(basename($ownerPath), $timestamp), $rootView);
399 399
 				}
400
-				self::move($rootView, $owner . '/files_versions/' . $ownerPath, $user . '/files_trashbin/versions/' . static::getTrashFilename($filename, $timestamp));
400
+				self::move($rootView, $owner.'/files_versions/'.$ownerPath, $user.'/files_trashbin/versions/'.static::getTrashFilename($filename, $timestamp));
401 401
 			} elseif ($versions = \OCA\Files_Versions\Storage::getVersions($owner, $ownerPath)) {
402 402
 				foreach ($versions as $v) {
403 403
 					if ($owner !== $user) {
404
-						self::copy($rootView, $owner . '/files_versions' . $v['path'] . '.v' . $v['version'], $owner . '/files_trashbin/versions/' . static::getTrashFilename($v['name'] . '.v' . $v['version'], $timestamp));
404
+						self::copy($rootView, $owner.'/files_versions'.$v['path'].'.v'.$v['version'], $owner.'/files_trashbin/versions/'.static::getTrashFilename($v['name'].'.v'.$v['version'], $timestamp));
405 405
 					}
406
-					self::move($rootView, $owner . '/files_versions' . $v['path'] . '.v' . $v['version'], $user . '/files_trashbin/versions/' . static::getTrashFilename($filename . '.v' . $v['version'], $timestamp));
406
+					self::move($rootView, $owner.'/files_versions'.$v['path'].'.v'.$v['version'], $user.'/files_trashbin/versions/'.static::getTrashFilename($filename.'.v'.$v['version'], $timestamp));
407 407
 				}
408 408
 			}
409 409
 		}
@@ -465,18 +465,18 @@  discard block
 block discarded – undo
465 465
 	 */
466 466
 	public static function restore($file, $filename, $timestamp) {
467 467
 		$user = OC_User::getUser();
468
-		$view = new View('/' . $user);
468
+		$view = new View('/'.$user);
469 469
 
470 470
 		$location = '';
471 471
 		if ($timestamp) {
472 472
 			$location = self::getLocation($user, $filename, $timestamp);
473 473
 			if ($location === false) {
474
-				\OC::$server->get(LoggerInterface::class)->error('trash bin database inconsistent! ($user: ' . $user . ' $filename: ' . $filename . ', $timestamp: ' . $timestamp . ')', ['app' => 'files_trashbin']);
474
+				\OC::$server->get(LoggerInterface::class)->error('trash bin database inconsistent! ($user: '.$user.' $filename: '.$filename.', $timestamp: '.$timestamp.')', ['app' => 'files_trashbin']);
475 475
 			} else {
476 476
 				// if location no longer exists, restore file in the root directory
477 477
 				if ($location !== '/' &&
478
-					(!$view->is_dir('files/' . $location) ||
479
-						!$view->isCreatable('files/' . $location))
478
+					(!$view->is_dir('files/'.$location) ||
479
+						!$view->isCreatable('files/'.$location))
480 480
 				) {
481 481
 					$location = '';
482 482
 				}
@@ -486,8 +486,8 @@  discard block
 block discarded – undo
486 486
 		// we need a  extension in case a file/dir with the same name already exists
487 487
 		$uniqueFilename = self::getUniqueFilename($location, $filename, $view);
488 488
 
489
-		$source = Filesystem::normalizePath('files_trashbin/files/' . $file);
490
-		$target = Filesystem::normalizePath('files/' . $location . '/' . $uniqueFilename);
489
+		$source = Filesystem::normalizePath('files_trashbin/files/'.$file);
490
+		$target = Filesystem::normalizePath('files/'.$location.'/'.$uniqueFilename);
491 491
 		if (!$view->file_exists($source)) {
492 492
 			return false;
493 493
 		}
@@ -502,10 +502,10 @@  discard block
 block discarded – undo
502 502
 		// handle the restore result
503 503
 		if ($restoreResult) {
504 504
 			$fakeRoot = $view->getRoot();
505
-			$view->chroot('/' . $user . '/files');
506
-			$view->touch('/' . $location . '/' . $uniqueFilename, $mtime);
505
+			$view->chroot('/'.$user.'/files');
506
+			$view->touch('/'.$location.'/'.$uniqueFilename, $mtime);
507 507
 			$view->chroot($fakeRoot);
508
-			\OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', ['filePath' => Filesystem::normalizePath('/' . $location . '/' . $uniqueFilename),
508
+			\OCP\Util::emitHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', ['filePath' => Filesystem::normalizePath('/'.$location.'/'.$uniqueFilename),
509 509
 				'trashPath' => Filesystem::normalizePath($file)]);
510 510
 
511 511
 			self::restoreVersions($view, $file, $filename, $uniqueFilename, $location, $timestamp);
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
 			$user = OC_User::getUser();
542 542
 			$rootView = new View('/');
543 543
 
544
-			$target = Filesystem::normalizePath('/' . $location . '/' . $uniqueFilename);
544
+			$target = Filesystem::normalizePath('/'.$location.'/'.$uniqueFilename);
545 545
 
546 546
 			[$owner, $ownerPath] = self::getUidAndFilename($target);
547 547
 
@@ -556,14 +556,14 @@  discard block
 block discarded – undo
556 556
 				$versionedFile = $file;
557 557
 			}
558 558
 
559
-			if ($view->is_dir('/files_trashbin/versions/' . $file)) {
560
-				$rootView->rename(Filesystem::normalizePath($user . '/files_trashbin/versions/' . $file), Filesystem::normalizePath($owner . '/files_versions/' . $ownerPath));
559
+			if ($view->is_dir('/files_trashbin/versions/'.$file)) {
560
+				$rootView->rename(Filesystem::normalizePath($user.'/files_trashbin/versions/'.$file), Filesystem::normalizePath($owner.'/files_versions/'.$ownerPath));
561 561
 			} elseif ($versions = self::getVersionsFromTrash($versionedFile, $timestamp, $user)) {
562 562
 				foreach ($versions as $v) {
563 563
 					if ($timestamp) {
564
-						$rootView->rename($user . '/files_trashbin/versions/' . static::getTrashFilename($versionedFile . '.v' . $v, $timestamp), $owner . '/files_versions/' . $ownerPath . '.v' . $v);
564
+						$rootView->rename($user.'/files_trashbin/versions/'.static::getTrashFilename($versionedFile.'.v'.$v, $timestamp), $owner.'/files_versions/'.$ownerPath.'.v'.$v);
565 565
 					} else {
566
-						$rootView->rename($user . '/files_trashbin/versions/' . $versionedFile . '.v' . $v, $owner . '/files_versions/' . $ownerPath . '.v' . $v);
566
+						$rootView->rename($user.'/files_trashbin/versions/'.$versionedFile.'.v'.$v, $owner.'/files_versions/'.$ownerPath.'.v'.$v);
567 567
 					}
568 568
 				}
569 569
 			}
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
 	public static function deleteAll() {
577 577
 		$user = OC_User::getUser();
578 578
 		$userRoot = \OC::$server->getUserFolder($user)->getParent();
579
-		$view = new View('/' . $user);
579
+		$view = new View('/'.$user);
580 580
 		$fileInfos = $view->getDirectoryContent('files_trashbin/files');
581 581
 
582 582
 		try {
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
 	 */
652 652
 	public static function delete($filename, $user, $timestamp = null) {
653 653
 		$userRoot = \OC::$server->getUserFolder($user)->getParent();
654
-		$view = new View('/' . $user);
654
+		$view = new View('/'.$user);
655 655
 		$size = 0;
656 656
 
657 657
 		if ($timestamp) {
@@ -670,20 +670,20 @@  discard block
 block discarded – undo
670 670
 		$size += self::deleteVersions($view, $file, $filename, $timestamp, $user);
671 671
 
672 672
 		try {
673
-			$node = $userRoot->get('/files_trashbin/files/' . $file);
673
+			$node = $userRoot->get('/files_trashbin/files/'.$file);
674 674
 		} catch (NotFoundException $e) {
675 675
 			return $size;
676 676
 		}
677 677
 
678 678
 		if ($node instanceof Folder) {
679
-			$size += self::calculateSize(new View('/' . $user . '/files_trashbin/files/' . $file));
679
+			$size += self::calculateSize(new View('/'.$user.'/files_trashbin/files/'.$file));
680 680
 		} elseif ($node instanceof File) {
681
-			$size += $view->filesize('/files_trashbin/files/' . $file);
681
+			$size += $view->filesize('/files_trashbin/files/'.$file);
682 682
 		}
683 683
 
684
-		self::emitTrashbinPreDelete('/files_trashbin/files/' . $file);
684
+		self::emitTrashbinPreDelete('/files_trashbin/files/'.$file);
685 685
 		$node->delete();
686
-		self::emitTrashbinPostDelete('/files_trashbin/files/' . $file);
686
+		self::emitTrashbinPostDelete('/files_trashbin/files/'.$file);
687 687
 
688 688
 		return $size;
689 689
 	}
@@ -699,17 +699,17 @@  discard block
 block discarded – undo
699 699
 	private static function deleteVersions(View $view, $file, $filename, $timestamp, $user) {
700 700
 		$size = 0;
701 701
 		if (\OCP\Server::get(IAppManager::class)->isEnabledForUser('files_versions')) {
702
-			if ($view->is_dir('files_trashbin/versions/' . $file)) {
703
-				$size += self::calculateSize(new View('/' . $user . '/files_trashbin/versions/' . $file));
704
-				$view->unlink('files_trashbin/versions/' . $file);
702
+			if ($view->is_dir('files_trashbin/versions/'.$file)) {
703
+				$size += self::calculateSize(new View('/'.$user.'/files_trashbin/versions/'.$file));
704
+				$view->unlink('files_trashbin/versions/'.$file);
705 705
 			} elseif ($versions = self::getVersionsFromTrash($filename, $timestamp, $user)) {
706 706
 				foreach ($versions as $v) {
707 707
 					if ($timestamp) {
708
-						$size += $view->filesize('/files_trashbin/versions/' . static::getTrashFilename($filename . '.v' . $v, $timestamp));
709
-						$view->unlink('/files_trashbin/versions/' . static::getTrashFilename($filename . '.v' . $v, $timestamp));
708
+						$size += $view->filesize('/files_trashbin/versions/'.static::getTrashFilename($filename.'.v'.$v, $timestamp));
709
+						$view->unlink('/files_trashbin/versions/'.static::getTrashFilename($filename.'.v'.$v, $timestamp));
710 710
 					} else {
711
-						$size += $view->filesize('/files_trashbin/versions/' . $filename . '.v' . $v);
712
-						$view->unlink('/files_trashbin/versions/' . $filename . '.v' . $v);
711
+						$size += $view->filesize('/files_trashbin/versions/'.$filename.'.v'.$v);
712
+						$view->unlink('/files_trashbin/versions/'.$filename.'.v'.$v);
713 713
 					}
714 714
 				}
715 715
 			}
@@ -726,13 +726,13 @@  discard block
 block discarded – undo
726 726
 	 */
727 727
 	public static function file_exists($filename, $timestamp = null) {
728 728
 		$user = OC_User::getUser();
729
-		$view = new View('/' . $user);
729
+		$view = new View('/'.$user);
730 730
 
731 731
 		if ($timestamp) {
732 732
 			$filename = static::getTrashFilename($filename, $timestamp);
733 733
 		}
734 734
 
735
-		$target = Filesystem::normalizePath('files_trashbin/files/' . $filename);
735
+		$target = Filesystem::normalizePath('files_trashbin/files/'.$filename);
736 736
 		return $view->file_exists($target);
737 737
 	}
738 738
 
@@ -758,11 +758,11 @@  discard block
 block discarded – undo
758 758
 	 */
759 759
 	private static function calculateFreeSpace($trashbinSize, $user) {
760 760
 		$config = \OC::$server->getConfig();
761
-		$userTrashbinSize = (int)$config->getUserValue($user, 'files_trashbin', 'trashbin_size', '-1');
761
+		$userTrashbinSize = (int) $config->getUserValue($user, 'files_trashbin', 'trashbin_size', '-1');
762 762
 		if ($userTrashbinSize > -1) {
763 763
 			return $userTrashbinSize - $trashbinSize;
764 764
 		}
765
-		$systemTrashbinSize = (int)$config->getAppValue('files_trashbin', 'trashbin_size', '-1');
765
+		$systemTrashbinSize = (int) $config->getAppValue('files_trashbin', 'trashbin_size', '-1');
766 766
 		if ($systemTrashbinSize > -1) {
767 767
 			return $systemTrashbinSize - $trashbinSize;
768 768
 		}
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
 			$availableSpace = $quota;
802 802
 		}
803 803
 
804
-		return (int)$availableSpace;
804
+		return (int) $availableSpace;
805 805
 	}
806 806
 
807 807
 	/**
@@ -871,7 +871,7 @@  discard block
 block discarded – undo
871 871
 			foreach ($files as $file) {
872 872
 				if ($availableSpace < 0 && $expiration->isExpired($file['mtime'], true)) {
873 873
 					$tmp = self::delete($file['name'], $user, $file['mtime']);
874
-					\OC::$server->get(LoggerInterface::class)->info('remove "' . $file['name'] . '" (' . $tmp . 'B) to meet the limit of trash bin size (50% of available quota)', ['app' => 'files_trashbin']);
874
+					\OC::$server->get(LoggerInterface::class)->info('remove "'.$file['name'].'" ('.$tmp.'B) to meet the limit of trash bin size (50% of available quota)', ['app' => 'files_trashbin']);
875 875
 					$availableSpace += $tmp;
876 876
 					$size += $tmp;
877 877
 				} else {
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
 					$size += self::delete($filename, $user, $timestamp);
903 903
 					$count++;
904 904
 				} catch (\OCP\Files\NotPermittedException $e) {
905
-					\OC::$server->get(LoggerInterface::class)->warning('Removing "' . $filename . '" from trashbin failed.',
905
+					\OC::$server->get(LoggerInterface::class)->warning('Removing "'.$filename.'" from trashbin failed.',
906 906
 						[
907 907
 							'exception' => $e,
908 908
 							'app' => 'files_trashbin',
@@ -910,7 +910,7 @@  discard block
 block discarded – undo
910 910
 					);
911 911
 				}
912 912
 				\OC::$server->get(LoggerInterface::class)->info(
913
-					'Remove "' . $filename . '" from trashbin because it exceeds max retention obligation term.',
913
+					'Remove "'.$filename.'" from trashbin because it exceeds max retention obligation term.',
914 914
 					['app' => 'files_trashbin']
915 915
 				);
916 916
 			} else {
@@ -936,16 +936,16 @@  discard block
 block discarded – undo
936 936
 			$view->mkdir($destination);
937 937
 			$view->touch($destination, $view->filemtime($source));
938 938
 			foreach ($view->getDirectoryContent($source) as $i) {
939
-				$pathDir = $source . '/' . $i['name'];
939
+				$pathDir = $source.'/'.$i['name'];
940 940
 				if ($view->is_dir($pathDir)) {
941
-					$size += self::copy_recursive($pathDir, $destination . '/' . $i['name'], $view);
941
+					$size += self::copy_recursive($pathDir, $destination.'/'.$i['name'], $view);
942 942
 				} else {
943 943
 					$size += $view->filesize($pathDir);
944
-					$result = $view->copy($pathDir, $destination . '/' . $i['name']);
944
+					$result = $view->copy($pathDir, $destination.'/'.$i['name']);
945 945
 					if (!$result) {
946 946
 						throw new \OCA\Files_Trashbin\Exceptions\CopyRecursiveException();
947 947
 					}
948
-					$view->touch($destination . '/' . $i['name'], $view->filemtime($pathDir));
948
+					$view->touch($destination.'/'.$i['name'], $view->filemtime($pathDir));
949 949
 				}
950 950
 			}
951 951
 		} else {
@@ -967,17 +967,17 @@  discard block
 block discarded – undo
967 967
 	 * @return array
968 968
 	 */
969 969
 	private static function getVersionsFromTrash($filename, $timestamp, $user) {
970
-		$view = new View('/' . $user . '/files_trashbin/versions');
970
+		$view = new View('/'.$user.'/files_trashbin/versions');
971 971
 		$versions = [];
972 972
 
973 973
 		/** @var \OC\Files\Storage\Storage $storage */
974
-		[$storage,] = $view->resolvePath('/');
974
+		[$storage, ] = $view->resolvePath('/');
975 975
 
976 976
 		$pattern = \OC::$server->getDatabaseConnection()->escapeLikeParameter(basename($filename));
977 977
 		if ($timestamp) {
978 978
 			// fetch for old versions
979 979
 			$escapedTimestamp = \OC::$server->getDatabaseConnection()->escapeLikeParameter($timestamp);
980
-			$pattern .= '.v%.d' . $escapedTimestamp;
980
+			$pattern .= '.v%.d'.$escapedTimestamp;
981 981
 			$offset = -strlen($escapedTimestamp) - 2;
982 982
 		} else {
983 983
 			$pattern .= '.v%';
@@ -990,7 +990,7 @@  discard block
 block discarded – undo
990 990
 			\OC::$server->getSystemConfig(),
991 991
 			\OC::$server->get(LoggerInterface::class)
992 992
 		);
993
-		$normalizedParentPath = ltrim(Filesystem::normalizePath(dirname('files_trashbin/versions/'. $filename)), '/');
993
+		$normalizedParentPath = ltrim(Filesystem::normalizePath(dirname('files_trashbin/versions/'.$filename)), '/');
994 994
 		$parentId = $cache->getId($normalizedParentPath);
995 995
 		if ($parentId === -1) {
996 996
 			return [];
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
 		$result->closeCursor();
1007 1007
 
1008 1008
 		/** @var CacheEntry[] $matches */
1009
-		$matches = array_map(function (array $data) {
1009
+		$matches = array_map(function(array $data) {
1010 1010
 			return Cache::cacheEntryFromData($data, \OC::$server->getMimeTypeLoader());
1011 1011
 		}, $entries);
1012 1012
 
@@ -1036,18 +1036,18 @@  discard block
 block discarded – undo
1036 1036
 		$name = pathinfo($filename, PATHINFO_FILENAME);
1037 1037
 		$l = \OC::$server->getL10N('files_trashbin');
1038 1038
 
1039
-		$location = '/' . trim($location, '/');
1039
+		$location = '/'.trim($location, '/');
1040 1040
 
1041 1041
 		// if extension is not empty we set a dot in front of it
1042 1042
 		if ($ext !== '') {
1043
-			$ext = '.' . $ext;
1043
+			$ext = '.'.$ext;
1044 1044
 		}
1045 1045
 
1046
-		if ($view->file_exists('files' . $location . '/' . $filename)) {
1046
+		if ($view->file_exists('files'.$location.'/'.$filename)) {
1047 1047
 			$i = 2;
1048
-			$uniqueName = $name . " (" . $l->t("restored") . ")" . $ext;
1049
-			while ($view->file_exists('files' . $location . '/' . $uniqueName)) {
1050
-				$uniqueName = $name . " (" . $l->t("restored") . " " . $i . ")" . $ext;
1048
+			$uniqueName = $name." (".$l->t("restored").")".$ext;
1049
+			while ($view->file_exists('files'.$location.'/'.$uniqueName)) {
1050
+				$uniqueName = $name." (".$l->t("restored")." ".$i.")".$ext;
1051 1051
 				$i++;
1052 1052
 			}
1053 1053
 
@@ -1064,7 +1064,7 @@  discard block
 block discarded – undo
1064 1064
 	 * @return integer size of the folder
1065 1065
 	 */
1066 1066
 	private static function calculateSize($view) {
1067
-		$root = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . $view->getAbsolutePath('');
1067
+		$root = \OC::$server->getConfig()->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data').$view->getAbsolutePath('');
1068 1068
 		if (!file_exists($root)) {
1069 1069
 			return 0;
1070 1070
 		}
@@ -1095,7 +1095,7 @@  discard block
 block discarded – undo
1095 1095
 	 * @return integer trash bin size
1096 1096
 	 */
1097 1097
 	private static function getTrashbinSize($user) {
1098
-		$view = new View('/' . $user);
1098
+		$view = new View('/'.$user);
1099 1099
 		$fileInfo = $view->getFileInfo('/files_trashbin');
1100 1100
 		return isset($fileInfo['size']) ? $fileInfo['size'] : 0;
1101 1101
 	}
@@ -1107,7 +1107,7 @@  discard block
 block discarded – undo
1107 1107
 	 * @return bool
1108 1108
 	 */
1109 1109
 	public static function isEmpty($user) {
1110
-		$view = new View('/' . $user . '/files_trashbin');
1110
+		$view = new View('/'.$user.'/files_trashbin');
1111 1111
 		if ($view->is_dir('/files') && $dh = $view->opendir('/files')) {
1112 1112
 			while ($file = readdir($dh)) {
1113 1113
 				if (!Filesystem::isIgnoredDir($file)) {
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
 	 * Return the filename used in the trash bin
1131 1131
 	 */
1132 1132
 	public static function getTrashFilename(string $filename, int $timestamp): string {
1133
-		$trashFilename = $filename . '.d' . $timestamp;
1133
+		$trashFilename = $filename.'.d'.$timestamp;
1134 1134
 		$length = strlen($trashFilename);
1135 1135
 		// oc_filecache `name` column has a limit of 250 chars
1136 1136
 		$maxLength = 250;
Please login to merge, or discard this patch.
apps/files_trashbin/lib/Trash/LegacyTrashBackend.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
 	private function mapTrashItems(array $items, IUser $user, ITrashItem $parent = null): array {
54 54
 		$parentTrashPath = ($parent instanceof ITrashItem) ? $parent->getTrashPath() : '';
55 55
 		$isRoot = $parent === null;
56
-		return array_map(function (FileInfo $file) use ($parent, $parentTrashPath, $isRoot, $user) {
57
-			$originalLocation = $isRoot ? $file['extraData'] : $parent->getOriginalLocation() . '/' . $file->getName();
56
+		return array_map(function(FileInfo $file) use ($parent, $parentTrashPath, $isRoot, $user) {
57
+			$originalLocation = $isRoot ? $file['extraData'] : $parent->getOriginalLocation().'/'.$file->getName();
58 58
 			if (!$originalLocation) {
59 59
 				$originalLocation = $file->getName();
60 60
 			}
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 				$this,
64 64
 				$originalLocation,
65 65
 				$file->getMTime(),
66
-				$parentTrashPath . '/' . ($isRoot ? $trashFilename : $file->getName()),
66
+				$parentTrashPath.'/'.($isRoot ? $trashFilename : $file->getName()),
67 67
 				$file,
68 68
 				$user
69 69
 			);
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	public function listTrashFolder(ITrashItem $folder): array {
79 79
 		$user = $folder->getUser();
80 80
 		$entries = Helper::getTrashFiles($folder->getTrashPath(), $user->getUID());
81
-		return $this->mapTrashItems($entries, $user ,$folder);
81
+		return $this->mapTrashItems($entries, $user, $folder);
82 82
 	}
83 83
 
84 84
 	public function restoreItem(ITrashItem $item) {
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	public function removeItem(ITrashItem $item) {
89 89
 		$user = $item->getUser();
90 90
 		if ($item->isRootItem()) {
91
-			$path = substr($item->getTrashPath(), 0, -strlen('.d' . $item->getDeletedTime()));
91
+			$path = substr($item->getTrashPath(), 0, -strlen('.d'.$item->getDeletedTime()));
92 92
 			Trashbin::delete($path, $user->getUID(), $item->getDeletedTime());
93 93
 		} else {
94 94
 			Trashbin::delete($item->getTrashPath(), $user->getUID(), null);
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 		if (!$storage instanceof Storage) {
100 100
 			return false;
101 101
 		}
102
-		$normalized = Filesystem::normalizePath($storage->getMountPoint() . '/' . $internalPath, true, false, true);
102
+		$normalized = Filesystem::normalizePath($storage->getMountPoint().'/'.$internalPath, true, false, true);
103 103
 		$view = Filesystem::getView();
104 104
 		if (!isset($this->deletedFiles[$normalized]) && $view instanceof View) {
105 105
 			$this->deletedFiles[$normalized] = $normalized;
Please login to merge, or discard this patch.