Completed
Push — master ( ff1dfc...e6bdfc )
by Robin
42:33 queued 24s
created
lib/private/Files/View.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -93,9 +93,9 @@  discard block
 block discarded – undo
93 93
 			$path = '/';
94 94
 		}
95 95
 		if ($path[0] !== '/') {
96
-			$path = '/' . $path;
96
+			$path = '/'.$path;
97 97
 		}
98
-		return $this->fakeRoot . $path;
98
+		return $this->fakeRoot.$path;
99 99
 	}
100 100
 
101 101
 	/**
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	public function chroot($fakeRoot): void {
107 107
 		if (!$fakeRoot == '') {
108 108
 			if ($fakeRoot[0] !== '/') {
109
-				$fakeRoot = '/' . $fakeRoot;
109
+				$fakeRoot = '/'.$fakeRoot;
110 110
 			}
111 111
 		}
112 112
 		$this->fakeRoot = $fakeRoot;
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 		}
136 136
 
137 137
 		// missing slashes can cause wrong matches!
138
-		$root = rtrim($this->fakeRoot, '/') . '/';
138
+		$root = rtrim($this->fakeRoot, '/').'/';
139 139
 
140 140
 		if (!str_starts_with($path, $root)) {
141 141
 			return null;
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	 *
193 193
 	 * @param string $path
194 194
 	 */
195
-	public function getLocalFile($path): string|false {
195
+	public function getLocalFile($path): string | false {
196 196
 		$parent = substr($path, 0, strrpos($path, '/') ?: 0);
197 197
 		$path = $this->getAbsolutePath($path);
198 198
 		[$storage, $internalPath] = Filesystem::resolvePath($path);
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 		if ($mount instanceof MoveableMount) {
223 223
 			// cut of /user/files to get the relative path to data/user/files
224 224
 			$pathParts = explode('/', $path, 4);
225
-			$relPath = '/' . $pathParts[3];
225
+			$relPath = '/'.$pathParts[3];
226 226
 			$this->lockFile($relPath, ILockingProvider::LOCK_SHARED, true);
227 227
 			\OC_Hook::emit(
228 228
 				Filesystem::CLASSNAME, 'umount',
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 		}
667 667
 		$postFix = (substr($path, -1) === '/') ? '/' : '';
668 668
 		$absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path));
669
-		$mount = Filesystem::getMountManager()->find($absolutePath . $postFix);
669
+		$mount = Filesystem::getMountManager()->find($absolutePath.$postFix);
670 670
 		if ($mount->getInternalPath($absolutePath) === '') {
671 671
 			return $this->removeMount($mount, $absolutePath);
672 672
 		}
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
 		$absolutePath1 = Filesystem::normalizePath($this->getAbsolutePath($source));
710 710
 		$absolutePath2 = Filesystem::normalizePath($this->getAbsolutePath($target));
711 711
 
712
-		if (str_starts_with($absolutePath2, $absolutePath1 . '/')) {
712
+		if (str_starts_with($absolutePath2, $absolutePath1.'/')) {
713 713
 			throw new ForbiddenException('Moving a folder into a child folder is forbidden', false);
714 714
 		}
715 715
 
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
 				$hooks[] = 'write';
1028 1028
 				break;
1029 1029
 			default:
1030
-				$this->logger->error('invalid mode (' . $mode . ') for ' . $path, ['app' => 'core']);
1030
+				$this->logger->error('invalid mode ('.$mode.') for '.$path, ['app' => 'core']);
1031 1031
 		}
1032 1032
 
1033 1033
 		if ($mode !== 'r' && $mode !== 'w') {
@@ -1051,7 +1051,7 @@  discard block
 block discarded – undo
1051 1051
 	 * @param string $path
1052 1052
 	 * @throws InvalidPathException
1053 1053
 	 */
1054
-	public function toTmpFile($path): string|false {
1054
+	public function toTmpFile($path): string | false {
1055 1055
 		$this->assertPathLength($path);
1056 1056
 		if (Filesystem::isValidPath($path)) {
1057 1057
 			$source = $this->fopen($path, 'r');
@@ -1126,7 +1126,7 @@  discard block
 block discarded – undo
1126 1126
 	 * @param string $path
1127 1127
 	 * @param bool $raw
1128 1128
 	 */
1129
-	public function hash($type, $path, $raw = false): string|bool {
1129
+	public function hash($type, $path, $raw = false): string | bool {
1130 1130
 		$postFix = (substr($path, -1) === '/') ? '/' : '';
1131 1131
 		$absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path));
1132 1132
 		if (Filesystem::isValidPath($path)) {
@@ -1142,7 +1142,7 @@  discard block
 block discarded – undo
1142 1142
 				);
1143 1143
 			}
1144 1144
 			/** @var Storage|null $storage */
1145
-			[$storage, $internalPath] = Filesystem::resolvePath($absolutePath . $postFix);
1145
+			[$storage, $internalPath] = Filesystem::resolvePath($absolutePath.$postFix);
1146 1146
 			if ($storage) {
1147 1147
 				return $storage->hash($type, $internalPath, $raw);
1148 1148
 			}
@@ -1192,7 +1192,7 @@  discard block
 block discarded – undo
1192 1192
 			}
1193 1193
 
1194 1194
 			$run = $this->runHooks($hooks, $path);
1195
-			[$storage, $internalPath] = Filesystem::resolvePath($absolutePath . $postFix);
1195
+			[$storage, $internalPath] = Filesystem::resolvePath($absolutePath.$postFix);
1196 1196
 			if ($run && $storage) {
1197 1197
 				/** @var Storage $storage */
1198 1198
 				if (in_array('write', $hooks) || in_array('delete', $hooks)) {
@@ -1240,7 +1240,7 @@  discard block
 block discarded – undo
1240 1240
 					$unlockLater = true;
1241 1241
 					// make sure our unlocking callback will still be called if connection is aborted
1242 1242
 					ignore_user_abort(true);
1243
-					$result = CallbackWrapper::wrap($result, null, null, function () use ($hooks, $path) {
1243
+					$result = CallbackWrapper::wrap($result, null, null, function() use ($hooks, $path) {
1244 1244
 						if (in_array('write', $hooks)) {
1245 1245
 							$this->unlockFile($path, ILockingProvider::LOCK_EXCLUSIVE);
1246 1246
 						} elseif (in_array('read', $hooks)) {
@@ -1302,7 +1302,7 @@  discard block
 block discarded – undo
1302 1302
 			return true;
1303 1303
 		}
1304 1304
 
1305
-		return (strlen($fullPath) > strlen($defaultRoot)) && (substr($fullPath, 0, strlen($defaultRoot) + 1) === $defaultRoot . '/');
1305
+		return (strlen($fullPath) > strlen($defaultRoot)) && (substr($fullPath, 0, strlen($defaultRoot) + 1) === $defaultRoot.'/');
1306 1306
 	}
1307 1307
 
1308 1308
 	/**
@@ -1321,7 +1321,7 @@  discard block
 block discarded – undo
1321 1321
 				if ($hook != 'read') {
1322 1322
 					\OC_Hook::emit(
1323 1323
 						Filesystem::CLASSNAME,
1324
-						$prefix . $hook,
1324
+						$prefix.$hook,
1325 1325
 						[
1326 1326
 							Filesystem::signal_param_run => &$run,
1327 1327
 							Filesystem::signal_param_path => $path
@@ -1330,7 +1330,7 @@  discard block
 block discarded – undo
1330 1330
 				} elseif (!$post) {
1331 1331
 					\OC_Hook::emit(
1332 1332
 						Filesystem::CLASSNAME,
1333
-						$prefix . $hook,
1333
+						$prefix.$hook,
1334 1334
 						[
1335 1335
 							Filesystem::signal_param_path => $path
1336 1336
 						]
@@ -1414,7 +1414,7 @@  discard block
 block discarded – undo
1414 1414
 			return false;
1415 1415
 		}
1416 1416
 		$relativePath = $path;
1417
-		$path = Filesystem::normalizePath($this->fakeRoot . '/' . $path);
1417
+		$path = Filesystem::normalizePath($this->fakeRoot.'/'.$path);
1418 1418
 
1419 1419
 		$mount = Filesystem::getMountManager()->find($path);
1420 1420
 		$storage = $mount->getStorage();
@@ -1455,7 +1455,7 @@  discard block
 block discarded – undo
1455 1455
 
1456 1456
 			return $info;
1457 1457
 		} else {
1458
-			$this->logger->warning('Storage not valid for mountpoint: ' . $mount->getMountPoint(), ['app' => 'core']);
1458
+			$this->logger->warning('Storage not valid for mountpoint: '.$mount->getMountPoint(), ['app' => 'core']);
1459 1459
 		}
1460 1460
 
1461 1461
 		return false;
@@ -1466,7 +1466,7 @@  discard block
 block discarded – undo
1466 1466
 	 */
1467 1467
 	public function addSubMounts(FileInfo $info, $extOnly = false): void {
1468 1468
 		$mounts = Filesystem::getMountManager()->findIn($info->getPath());
1469
-		$info->setSubMounts(array_filter($mounts, function (IMountPoint $mount) use ($extOnly) {
1469
+		$info->setSubMounts(array_filter($mounts, function(IMountPoint $mount) use ($extOnly) {
1470 1470
 			return !($extOnly && $mount instanceof SharedMount);
1471 1471
 		}));
1472 1472
 	}
@@ -1514,13 +1514,13 @@  discard block
 block discarded – undo
1514 1514
 
1515 1515
 		$sharingDisabled = \OCP\Util::isSharingDisabledForUser();
1516 1516
 
1517
-		$fileNames = array_map(function (ICacheEntry $content) {
1517
+		$fileNames = array_map(function(ICacheEntry $content) {
1518 1518
 			return $content->getName();
1519 1519
 		}, $contents);
1520 1520
 		/**
1521 1521
 		 * @var \OC\Files\FileInfo[] $fileInfos
1522 1522
 		 */
1523
-		$fileInfos = array_map(function (ICacheEntry $content) use ($path, $storage, $mount, $sharingDisabled) {
1523
+		$fileInfos = array_map(function(ICacheEntry $content) use ($path, $storage, $mount, $sharingDisabled) {
1524 1524
 			if ($sharingDisabled) {
1525 1525
 				$content['permissions'] = $content['permissions'] & ~\OCP\Constants::PERMISSION_SHARE;
1526 1526
 			}
@@ -1530,7 +1530,7 @@  discard block
 block discarded – undo
1530 1530
 			} else {
1531 1531
 				$owner = null;
1532 1532
 			}
1533
-			return new FileInfo($path . '/' . $content['name'], $storage, $content['path'], $content, $mount, $owner);
1533
+			return new FileInfo($path.'/'.$content['name'], $storage, $content['path'], $content, $mount, $owner);
1534 1534
 		}, $contents);
1535 1535
 		$files = array_combine($fileNames, $fileInfos);
1536 1536
 
@@ -1539,7 +1539,7 @@  discard block
 block discarded – undo
1539 1539
 
1540 1540
 		// make sure nested mounts are sorted after their parent mounts
1541 1541
 		// otherwise doesn't propagate the etag across storage boundaries correctly
1542
-		usort($mounts, function (IMountPoint $a, IMountPoint $b) {
1542
+		usort($mounts, function(IMountPoint $a, IMountPoint $b) {
1543 1543
 			return $a->getMountPoint() <=> $b->getMountPoint();
1544 1544
 		});
1545 1545
 
@@ -1561,7 +1561,7 @@  discard block
 block discarded – undo
1561 1561
 						continue;
1562 1562
 					} catch (\Exception $e) {
1563 1563
 						// sometimes when the storage is not available it can be any exception
1564
-						$this->logger->error('Exception while scanning storage "' . $subStorage->getId() . '"', [
1564
+						$this->logger->error('Exception while scanning storage "'.$subStorage->getId().'"', [
1565 1565
 							'exception' => $e,
1566 1566
 							'app' => 'core',
1567 1567
 						]);
@@ -1579,14 +1579,14 @@  discard block
 block discarded – undo
1579 1579
 						// Create parent folders if the mountpoint is inside a subfolder that doesn't exist yet
1580 1580
 						if (!isset($files[$entryName])) {
1581 1581
 							try {
1582
-								[$storage, ] = $this->resolvePath($path . '/' . $entryName);
1582
+								[$storage, ] = $this->resolvePath($path.'/'.$entryName);
1583 1583
 								// make sure we can create the mountpoint folder, even if the user has a quota of 0
1584 1584
 								if ($storage->instanceOfStorage(Quota::class)) {
1585 1585
 									$storage->enableQuota(false);
1586 1586
 								}
1587 1587
 
1588
-								if ($this->mkdir($path . '/' . $entryName) !== false) {
1589
-									$info = $this->getFileInfo($path . '/' . $entryName);
1588
+								if ($this->mkdir($path.'/'.$entryName) !== false) {
1589
+									$info = $this->getFileInfo($path.'/'.$entryName);
1590 1590
 									if ($info !== false) {
1591 1591
 										$files[$entryName] = $info;
1592 1592
 									}
@@ -1597,7 +1597,7 @@  discard block
 block discarded – undo
1597 1597
 								}
1598 1598
 							} catch (\Exception $e) {
1599 1599
 								// Creating the parent folder might not be possible, for example due to a lack of permissions.
1600
-								$this->logger->debug('Failed to create non-existent parent', ['exception' => $e, 'path' => $path . '/' . $entryName]);
1600
+								$this->logger->debug('Failed to create non-existent parent', ['exception' => $e, 'path' => $path.'/'.$entryName]);
1601 1601
 							}
1602 1602
 						}
1603 1603
 
@@ -1616,7 +1616,7 @@  discard block
 block discarded – undo
1616 1616
 							$rootEntry['permissions'] = $permissions & (\OCP\Constants::PERMISSION_ALL - (\OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE));
1617 1617
 						}
1618 1618
 
1619
-						$rootEntry['path'] = substr(Filesystem::normalizePath($path . '/' . $rootEntry['name']), strlen($user) + 2); // full path without /$user/
1619
+						$rootEntry['path'] = substr(Filesystem::normalizePath($path.'/'.$rootEntry['name']), strlen($user) + 2); // full path without /$user/
1620 1620
 
1621 1621
 						// if sharing was disabled for the user we remove the share permissions
1622 1622
 						if ($sharingDisabled) {
@@ -1629,14 +1629,14 @@  discard block
 block discarded – undo
1629 1629
 						} else {
1630 1630
 							$owner = null;
1631 1631
 						}
1632
-						$files[$rootEntry->getName()] = new FileInfo($path . '/' . $rootEntry['name'], $subStorage, '', $rootEntry, $mount, $owner);
1632
+						$files[$rootEntry->getName()] = new FileInfo($path.'/'.$rootEntry['name'], $subStorage, '', $rootEntry, $mount, $owner);
1633 1633
 					}
1634 1634
 				}
1635 1635
 			}
1636 1636
 		}
1637 1637
 
1638 1638
 		if ($mimetype_filter) {
1639
-			$files = array_filter($files, function (FileInfo $file) use ($mimetype_filter) {
1639
+			$files = array_filter($files, function(FileInfo $file) use ($mimetype_filter) {
1640 1640
 				if (strpos($mimetype_filter, '/')) {
1641 1641
 					return $file->getMimetype() === $mimetype_filter;
1642 1642
 				} else {
@@ -1662,7 +1662,7 @@  discard block
 block discarded – undo
1662 1662
 		if ($data instanceof FileInfo) {
1663 1663
 			$data = $data->getData();
1664 1664
 		}
1665
-		$path = Filesystem::normalizePath($this->fakeRoot . '/' . $path);
1665
+		$path = Filesystem::normalizePath($this->fakeRoot.'/'.$path);
1666 1666
 		/**
1667 1667
 		 * @var Storage $storage
1668 1668
 		 * @var string $internalPath
@@ -1689,7 +1689,7 @@  discard block
 block discarded – undo
1689 1689
 	 * @return FileInfo[]
1690 1690
 	 */
1691 1691
 	public function search($query) {
1692
-		return $this->searchCommon('search', ['%' . $query . '%']);
1692
+		return $this->searchCommon('search', ['%'.$query.'%']);
1693 1693
 	}
1694 1694
 
1695 1695
 	/**
@@ -1741,10 +1741,10 @@  discard block
 block discarded – undo
1741 1741
 
1742 1742
 			$results = call_user_func_array([$cache, $method], $args);
1743 1743
 			foreach ($results as $result) {
1744
-				if (substr($mountPoint . $result['path'], 0, $rootLength + 1) === $this->fakeRoot . '/') {
1744
+				if (substr($mountPoint.$result['path'], 0, $rootLength + 1) === $this->fakeRoot.'/') {
1745 1745
 					$internalPath = $result['path'];
1746
-					$path = $mountPoint . $result['path'];
1747
-					$result['path'] = substr($mountPoint . $result['path'], $rootLength);
1746
+					$path = $mountPoint.$result['path'];
1747
+					$result['path'] = substr($mountPoint.$result['path'], $rootLength);
1748 1748
 					$ownerId = $storage->getOwner($internalPath);
1749 1749
 					if ($ownerId !== false) {
1750 1750
 						$owner = $userManager->get($ownerId);
@@ -1767,8 +1767,8 @@  discard block
 block discarded – undo
1767 1767
 					if ($results) {
1768 1768
 						foreach ($results as $result) {
1769 1769
 							$internalPath = $result['path'];
1770
-							$result['path'] = rtrim($relativeMountPoint . $result['path'], '/');
1771
-							$path = rtrim($mountPoint . $internalPath, '/');
1770
+							$result['path'] = rtrim($relativeMountPoint.$result['path'], '/');
1771
+							$path = rtrim($mountPoint.$internalPath, '/');
1772 1772
 							$ownerId = $storage->getOwner($internalPath);
1773 1773
 							if ($ownerId !== false) {
1774 1774
 								$owner = $userManager->get($ownerId);
@@ -1792,11 +1792,11 @@  discard block
 block discarded – undo
1792 1792
 	public function getOwner(string $path): string {
1793 1793
 		$info = $this->getFileInfo($path);
1794 1794
 		if (!$info) {
1795
-			throw new NotFoundException($path . ' not found while trying to get owner');
1795
+			throw new NotFoundException($path.' not found while trying to get owner');
1796 1796
 		}
1797 1797
 
1798 1798
 		if ($info->getOwner() === null) {
1799
-			throw new NotFoundException($path . ' has no owner');
1799
+			throw new NotFoundException($path.' has no owner');
1800 1800
 		}
1801 1801
 
1802 1802
 		return $info->getOwner()->getUID();
@@ -1828,7 +1828,7 @@  discard block
 block discarded – undo
1828 1828
 	 * @throws NotFoundException
1829 1829
 	 */
1830 1830
 	public function getPath($id, ?int $storageId = null) {
1831
-		$id = (int)$id;
1831
+		$id = (int) $id;
1832 1832
 		$manager = Filesystem::getMountManager();
1833 1833
 		$mounts = $manager->findIn($this->fakeRoot);
1834 1834
 		$mounts[] = $manager->find($this->fakeRoot);
@@ -1839,12 +1839,12 @@  discard block
 block discarded – undo
1839 1839
 
1840 1840
 		// put non-shared mounts in front of the shared mount
1841 1841
 		// this prevents unneeded recursion into shares
1842
-		usort($mounts, function (IMountPoint $a, IMountPoint $b) {
1842
+		usort($mounts, function(IMountPoint $a, IMountPoint $b) {
1843 1843
 			return $a instanceof SharedMount && (!$b instanceof SharedMount) ? 1 : -1;
1844 1844
 		});
1845 1845
 
1846 1846
 		if (!is_null($storageId)) {
1847
-			$mounts = array_filter($mounts, function (IMountPoint $mount) use ($storageId) {
1847
+			$mounts = array_filter($mounts, function(IMountPoint $mount) use ($storageId) {
1848 1848
 				return $mount->getNumericStorageId() === $storageId;
1849 1849
 			});
1850 1850
 		}
@@ -1857,7 +1857,7 @@  discard block
 block discarded – undo
1857 1857
 				$cache = $mount->getStorage()->getCache();
1858 1858
 				$internalPath = $cache->getPathById($id);
1859 1859
 				if (is_string($internalPath)) {
1860
-					$fullPath = $mount->getMountPoint() . $internalPath;
1860
+					$fullPath = $mount->getMountPoint().$internalPath;
1861 1861
 					if (!is_null($path = $this->getRelativePath($fullPath))) {
1862 1862
 						return $path;
1863 1863
 					}
@@ -1898,13 +1898,13 @@  discard block
 block discarded – undo
1898 1898
 		];
1899 1899
 		$shareManager = Server::get(IManager::class);
1900 1900
 		/** @var IShare[] $shares */
1901
-		$shares = array_merge(...array_map(function (int $type) use ($shareManager, $user) {
1901
+		$shares = array_merge(...array_map(function(int $type) use ($shareManager, $user) {
1902 1902
 			return $shareManager->getSharesBy($user, $type);
1903 1903
 		}, $providers));
1904 1904
 
1905 1905
 		foreach ($shares as $share) {
1906 1906
 			$sharedPath = $share->getNode()->getPath();
1907
-			if ($targetPath === $sharedPath || str_starts_with($targetPath, $sharedPath . '/')) {
1907
+			if ($targetPath === $sharedPath || str_starts_with($targetPath, $sharedPath.'/')) {
1908 1908
 				$this->logger->debug(
1909 1909
 					'It is not allowed to move one mount point into a shared folder',
1910 1910
 					['app' => 'files']);
@@ -2012,7 +2012,7 @@  discard block
 block discarded – undo
2012 2012
 		$resultPath = '';
2013 2013
 		foreach ($parts as $part) {
2014 2014
 			if ($part) {
2015
-				$resultPath .= '/' . $part;
2015
+				$resultPath .= '/'.$part;
2016 2016
 				$result[] = $resultPath;
2017 2017
 			}
2018 2018
 		}
@@ -2263,16 +2263,16 @@  discard block
 block discarded – undo
2263 2263
 	public function getUidAndFilename($filename) {
2264 2264
 		$info = $this->getFileInfo($filename);
2265 2265
 		if (!$info instanceof \OCP\Files\FileInfo) {
2266
-			throw new NotFoundException($this->getAbsolutePath($filename) . ' not found');
2266
+			throw new NotFoundException($this->getAbsolutePath($filename).' not found');
2267 2267
 		}
2268 2268
 		$uid = $info->getOwner()->getUID();
2269 2269
 		if ($uid != \OC_User::getUser()) {
2270 2270
 			Filesystem::initMountPoints($uid);
2271
-			$ownerView = new View('/' . $uid . '/files');
2271
+			$ownerView = new View('/'.$uid.'/files');
2272 2272
 			try {
2273 2273
 				$filename = $ownerView->getPath($info['fileid']);
2274 2274
 			} catch (NotFoundException $e) {
2275
-				throw new NotFoundException('File with id ' . $info['fileid'] . ' not found for user ' . $uid);
2275
+				throw new NotFoundException('File with id '.$info['fileid'].' not found for user '.$uid);
2276 2276
 			}
2277 2277
 		}
2278 2278
 		return [$uid, $filename];
@@ -2289,7 +2289,7 @@  discard block
 block discarded – undo
2289 2289
 		$directoryParts = array_filter($directoryParts);
2290 2290
 		foreach ($directoryParts as $key => $part) {
2291 2291
 			$currentPathElements = array_slice($directoryParts, 0, $key);
2292
-			$currentPath = '/' . implode('/', $currentPathElements);
2292
+			$currentPath = '/'.implode('/', $currentPathElements);
2293 2293
 			if ($this->is_file($currentPath)) {
2294 2294
 				return false;
2295 2295
 			}
Please login to merge, or discard this patch.