Passed
Push — master ( 0d3330...90e985 )
by Morris
14:41
created
lib/private/Files/View.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -127,9 +127,9 @@  discard block
 block discarded – undo
127 127
 			$path = '/';
128 128
 		}
129 129
 		if ($path[0] !== '/') {
130
-			$path = '/' . $path;
130
+			$path = '/'.$path;
131 131
 		}
132
-		return $this->fakeRoot . $path;
132
+		return $this->fakeRoot.$path;
133 133
 	}
134 134
 
135 135
 	/**
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	public function chroot($fakeRoot) {
142 142
 		if (!$fakeRoot == '') {
143 143
 			if ($fakeRoot[0] !== '/') {
144
-				$fakeRoot = '/' . $fakeRoot;
144
+				$fakeRoot = '/'.$fakeRoot;
145 145
 			}
146 146
 		}
147 147
 		$this->fakeRoot = $fakeRoot;
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 		}
174 174
 
175 175
 		// missing slashes can cause wrong matches!
176
-		$root = rtrim($this->fakeRoot, '/') . '/';
176
+		$root = rtrim($this->fakeRoot, '/').'/';
177 177
 
178 178
 		if (strpos($path, $root) !== 0) {
179 179
 			return null;
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 		if ($mount instanceof MoveableMount) {
280 280
 			// cut of /user/files to get the relative path to data/user/files
281 281
 			$pathParts = explode('/', $path, 4);
282
-			$relPath = '/' . $pathParts[3];
282
+			$relPath = '/'.$pathParts[3];
283 283
 			$this->lockFile($relPath, ILockingProvider::LOCK_SHARED, true);
284 284
 			\OC_Hook::emit(
285 285
 				Filesystem::CLASSNAME, "umount",
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
 		}
700 700
 		$postFix = (substr($path, -1) === '/') ? '/' : '';
701 701
 		$absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path));
702
-		$mount = Filesystem::getMountManager()->find($absolutePath . $postFix);
702
+		$mount = Filesystem::getMountManager()->find($absolutePath.$postFix);
703 703
 		if ($mount and $mount->getInternalPath($absolutePath) === '') {
704 704
 			return $this->removeMount($mount, $absolutePath);
705 705
 		}
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
 								$this->renameUpdate($storage1, $storage2, $internalPath1, $internalPath2);
820 820
 							}
821 821
 						}
822
-					} catch(\Exception $e) {
822
+					} catch (\Exception $e) {
823 823
 						throw $e;
824 824
 					} finally {
825 825
 						$this->changeLock($path1, ILockingProvider::LOCK_SHARED, true);
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
 						}
844 844
 					}
845 845
 				}
846
-			} catch(\Exception $e) {
846
+			} catch (\Exception $e) {
847 847
 				throw $e;
848 848
 			} finally {
849 849
 				$this->unlockFile($path1, ILockingProvider::LOCK_SHARED, true);
@@ -976,7 +976,7 @@  discard block
 block discarded – undo
976 976
 				$hooks[] = 'write';
977 977
 				break;
978 978
 			default:
979
-				\OCP\Util::writeLog('core', 'invalid mode (' . $mode . ') for ' . $path, ILogger::ERROR);
979
+				\OCP\Util::writeLog('core', 'invalid mode ('.$mode.') for '.$path, ILogger::ERROR);
980 980
 		}
981 981
 
982 982
 		if ($mode !== 'r' && $mode !== 'w') {
@@ -1080,7 +1080,7 @@  discard block
 block discarded – undo
1080 1080
 					array(Filesystem::signal_param_path => $this->getHookPath($path))
1081 1081
 				);
1082 1082
 			}
1083
-			list($storage, $internalPath) = Filesystem::resolvePath($absolutePath . $postFix);
1083
+			list($storage, $internalPath) = Filesystem::resolvePath($absolutePath.$postFix);
1084 1084
 			if ($storage) {
1085 1085
 				return $storage->hash($type, $internalPath, $raw);
1086 1086
 			}
@@ -1134,7 +1134,7 @@  discard block
 block discarded – undo
1134 1134
 
1135 1135
 			$run = $this->runHooks($hooks, $path);
1136 1136
 			/** @var \OC\Files\Storage\Storage $storage */
1137
-			list($storage, $internalPath) = Filesystem::resolvePath($absolutePath . $postFix);
1137
+			list($storage, $internalPath) = Filesystem::resolvePath($absolutePath.$postFix);
1138 1138
 			if ($run and $storage) {
1139 1139
 				if (in_array('write', $hooks) || in_array('delete', $hooks)) {
1140 1140
 					try {
@@ -1163,7 +1163,7 @@  discard block
 block discarded – undo
1163 1163
 				if ($result && in_array('delete', $hooks) and $result) {
1164 1164
 					$this->removeUpdate($storage, $internalPath);
1165 1165
 				}
1166
-				if ($result && in_array('write', $hooks,  true) && $operation !== 'fopen' && $operation !== 'touch') {
1166
+				if ($result && in_array('write', $hooks, true) && $operation !== 'fopen' && $operation !== 'touch') {
1167 1167
 					$this->writeUpdate($storage, $internalPath);
1168 1168
 				}
1169 1169
 				if ($result && in_array('touch', $hooks)) {
@@ -1179,7 +1179,7 @@  discard block
 block discarded – undo
1179 1179
 					$unlockLater = true;
1180 1180
 					// make sure our unlocking callback will still be called if connection is aborted
1181 1181
 					ignore_user_abort(true);
1182
-					$result = CallbackWrapper::wrap($result, null, null, function () use ($hooks, $path) {
1182
+					$result = CallbackWrapper::wrap($result, null, null, function() use ($hooks, $path) {
1183 1183
 						if (in_array('write', $hooks)) {
1184 1184
 							$this->unlockFile($path, ILockingProvider::LOCK_EXCLUSIVE);
1185 1185
 						} else if (in_array('read', $hooks)) {
@@ -1240,7 +1240,7 @@  discard block
 block discarded – undo
1240 1240
 			return true;
1241 1241
 		}
1242 1242
 
1243
-		return (strlen($fullPath) > strlen($defaultRoot)) && (substr($fullPath, 0, strlen($defaultRoot) + 1) === $defaultRoot . '/');
1243
+		return (strlen($fullPath) > strlen($defaultRoot)) && (substr($fullPath, 0, strlen($defaultRoot) + 1) === $defaultRoot.'/');
1244 1244
 	}
1245 1245
 
1246 1246
 	/**
@@ -1259,7 +1259,7 @@  discard block
 block discarded – undo
1259 1259
 				if ($hook != 'read') {
1260 1260
 					\OC_Hook::emit(
1261 1261
 						Filesystem::CLASSNAME,
1262
-						$prefix . $hook,
1262
+						$prefix.$hook,
1263 1263
 						array(
1264 1264
 							Filesystem::signal_param_run => &$run,
1265 1265
 							Filesystem::signal_param_path => $path
@@ -1268,7 +1268,7 @@  discard block
 block discarded – undo
1268 1268
 				} elseif (!$post) {
1269 1269
 					\OC_Hook::emit(
1270 1270
 						Filesystem::CLASSNAME,
1271
-						$prefix . $hook,
1271
+						$prefix.$hook,
1272 1272
 						array(
1273 1273
 							Filesystem::signal_param_path => $path
1274 1274
 						)
@@ -1361,11 +1361,11 @@  discard block
 block discarded – undo
1361 1361
 			return $this->getPartFileInfo($path);
1362 1362
 		}
1363 1363
 		$relativePath = $path;
1364
-		$path = Filesystem::normalizePath($this->fakeRoot . '/' . $path);
1364
+		$path = Filesystem::normalizePath($this->fakeRoot.'/'.$path);
1365 1365
 
1366 1366
 		$mount = Filesystem::getMountManager()->find($path);
1367 1367
 		if (!$mount) {
1368
-			\OC::$server->getLogger()->warning('Mountpoint not found for path: ' . $path);
1368
+			\OC::$server->getLogger()->warning('Mountpoint not found for path: '.$path);
1369 1369
 			return false;
1370 1370
 		}
1371 1371
 		$storage = $mount->getStorage();
@@ -1374,7 +1374,7 @@  discard block
 block discarded – undo
1374 1374
 			$data = $this->getCacheEntry($storage, $internalPath, $relativePath);
1375 1375
 
1376 1376
 			if (!$data instanceof ICacheEntry) {
1377
-				\OC::$server->getLogger()->debug('No cache entry found for ' . $path . ' (storage: ' . $storage->getId() . ', internalPath: ' . $internalPath . ')');
1377
+				\OC::$server->getLogger()->debug('No cache entry found for '.$path.' (storage: '.$storage->getId().', internalPath: '.$internalPath.')');
1378 1378
 				return false;
1379 1379
 			}
1380 1380
 
@@ -1390,7 +1390,7 @@  discard block
 block discarded – undo
1390 1390
 					//add the sizes of other mount points to the folder
1391 1391
 					$extOnly = ($includeMountPoints === 'ext');
1392 1392
 					$mounts = Filesystem::getMountManager()->findIn($path);
1393
-					$info->setSubMounts(array_filter($mounts, function (IMountPoint $mount) use ($extOnly) {
1393
+					$info->setSubMounts(array_filter($mounts, function(IMountPoint $mount) use ($extOnly) {
1394 1394
 						$subStorage = $mount->getStorage();
1395 1395
 						return !($extOnly && $subStorage instanceof \OCA\Files_Sharing\SharedStorage);
1396 1396
 					}));
@@ -1399,7 +1399,7 @@  discard block
 block discarded – undo
1399 1399
 
1400 1400
 			return $info;
1401 1401
 		} else {
1402
-			\OC::$server->getLogger()->warning('Storage not valid for mountpoint: ' . $mount->getMountPoint());
1402
+			\OC::$server->getLogger()->warning('Storage not valid for mountpoint: '.$mount->getMountPoint());
1403 1403
 		}
1404 1404
 
1405 1405
 		return false;
@@ -1446,12 +1446,12 @@  discard block
 block discarded – undo
1446 1446
 			/**
1447 1447
 			 * @var \OC\Files\FileInfo[] $fileInfos
1448 1448
 			 */
1449
-			$fileInfos = array_map(function (ICacheEntry $content) use ($path, $storage, $mount, $sharingDisabled) {
1449
+			$fileInfos = array_map(function(ICacheEntry $content) use ($path, $storage, $mount, $sharingDisabled) {
1450 1450
 				if ($sharingDisabled) {
1451 1451
 					$content['permissions'] = $content['permissions'] & ~\OCP\Constants::PERMISSION_SHARE;
1452 1452
 				}
1453 1453
 				$owner = $this->getUserObjectForOwner($storage->getOwner($content['path']));
1454
-				return new FileInfo($path . '/' . $content['name'], $storage, $content['path'], $content, $mount, $owner);
1454
+				return new FileInfo($path.'/'.$content['name'], $storage, $content['path'], $content, $mount, $owner);
1455 1455
 			}, $contents);
1456 1456
 			$files = array_combine($fileNames, $fileInfos);
1457 1457
 
@@ -1476,7 +1476,7 @@  discard block
 block discarded – undo
1476 1476
 						} catch (\Exception $e) {
1477 1477
 							// sometimes when the storage is not available it can be any exception
1478 1478
 							\OC::$server->getLogger()->logException($e, [
1479
-								'message' => 'Exception while scanning storage "' . $subStorage->getId() . '"',
1479
+								'message' => 'Exception while scanning storage "'.$subStorage->getId().'"',
1480 1480
 								'level' => ILogger::ERROR,
1481 1481
 								'app' => 'lib',
1482 1482
 							]);
@@ -1507,7 +1507,7 @@  discard block
 block discarded – undo
1507 1507
 								$rootEntry['permissions'] = $permissions & (\OCP\Constants::PERMISSION_ALL - (\OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE));
1508 1508
 							}
1509 1509
 
1510
-							$rootEntry['path'] = substr(Filesystem::normalizePath($path . '/' . $rootEntry['name']), strlen($user) + 2); // full path without /$user/
1510
+							$rootEntry['path'] = substr(Filesystem::normalizePath($path.'/'.$rootEntry['name']), strlen($user) + 2); // full path without /$user/
1511 1511
 
1512 1512
 							// if sharing was disabled for the user we remove the share permissions
1513 1513
 							if (\OCP\Util::isSharingDisabledForUser()) {
@@ -1515,14 +1515,14 @@  discard block
 block discarded – undo
1515 1515
 							}
1516 1516
 
1517 1517
 							$owner = $this->getUserObjectForOwner($subStorage->getOwner(''));
1518
-							$files[$rootEntry->getName()] = new FileInfo($path . '/' . $rootEntry['name'], $subStorage, '', $rootEntry, $mount, $owner);
1518
+							$files[$rootEntry->getName()] = new FileInfo($path.'/'.$rootEntry['name'], $subStorage, '', $rootEntry, $mount, $owner);
1519 1519
 						}
1520 1520
 					}
1521 1521
 				}
1522 1522
 			}
1523 1523
 
1524 1524
 			if ($mimetype_filter) {
1525
-				$files = array_filter($files, function (FileInfo $file) use ($mimetype_filter) {
1525
+				$files = array_filter($files, function(FileInfo $file) use ($mimetype_filter) {
1526 1526
 					if (strpos($mimetype_filter, '/')) {
1527 1527
 						return $file->getMimetype() === $mimetype_filter;
1528 1528
 					} else {
@@ -1551,7 +1551,7 @@  discard block
 block discarded – undo
1551 1551
 		if ($data instanceof FileInfo) {
1552 1552
 			$data = $data->getData();
1553 1553
 		}
1554
-		$path = Filesystem::normalizePath($this->fakeRoot . '/' . $path);
1554
+		$path = Filesystem::normalizePath($this->fakeRoot.'/'.$path);
1555 1555
 		/**
1556 1556
 		 * @var \OC\Files\Storage\Storage $storage
1557 1557
 		 * @var string $internalPath
@@ -1578,7 +1578,7 @@  discard block
 block discarded – undo
1578 1578
 	 * @return FileInfo[]
1579 1579
 	 */
1580 1580
 	public function search($query) {
1581
-		return $this->searchCommon('search', array('%' . $query . '%'));
1581
+		return $this->searchCommon('search', array('%'.$query.'%'));
1582 1582
 	}
1583 1583
 
1584 1584
 	/**
@@ -1629,10 +1629,10 @@  discard block
 block discarded – undo
1629 1629
 
1630 1630
 			$results = call_user_func_array(array($cache, $method), $args);
1631 1631
 			foreach ($results as $result) {
1632
-				if (substr($mountPoint . $result['path'], 0, $rootLength + 1) === $this->fakeRoot . '/') {
1632
+				if (substr($mountPoint.$result['path'], 0, $rootLength + 1) === $this->fakeRoot.'/') {
1633 1633
 					$internalPath = $result['path'];
1634
-					$path = $mountPoint . $result['path'];
1635
-					$result['path'] = substr($mountPoint . $result['path'], $rootLength);
1634
+					$path = $mountPoint.$result['path'];
1635
+					$result['path'] = substr($mountPoint.$result['path'], $rootLength);
1636 1636
 					$owner = \OC::$server->getUserManager()->get($storage->getOwner($internalPath));
1637 1637
 					$files[] = new FileInfo($path, $storage, $internalPath, $result, $mount, $owner);
1638 1638
 				}
@@ -1650,8 +1650,8 @@  discard block
 block discarded – undo
1650 1650
 					if ($results) {
1651 1651
 						foreach ($results as $result) {
1652 1652
 							$internalPath = $result['path'];
1653
-							$result['path'] = rtrim($relativeMountPoint . $result['path'], '/');
1654
-							$path = rtrim($mountPoint . $internalPath, '/');
1653
+							$result['path'] = rtrim($relativeMountPoint.$result['path'], '/');
1654
+							$path = rtrim($mountPoint.$internalPath, '/');
1655 1655
 							$owner = \OC::$server->getUserManager()->get($storage->getOwner($internalPath));
1656 1656
 							$files[] = new FileInfo($path, $storage, $internalPath, $result, $mount, $owner);
1657 1657
 						}
@@ -1672,7 +1672,7 @@  discard block
 block discarded – undo
1672 1672
 	public function getOwner($path) {
1673 1673
 		$info = $this->getFileInfo($path);
1674 1674
 		if (!$info) {
1675
-			throw new NotFoundException($path . ' not found while trying to get owner');
1675
+			throw new NotFoundException($path.' not found while trying to get owner');
1676 1676
 		}
1677 1677
 		return $info->getOwner()->getUID();
1678 1678
 	}
@@ -1706,7 +1706,7 @@  discard block
 block discarded – undo
1706 1706
 	 * @return string
1707 1707
 	 */
1708 1708
 	public function getPath($id) {
1709
-		$id = (int)$id;
1709
+		$id = (int) $id;
1710 1710
 		$manager = Filesystem::getMountManager();
1711 1711
 		$mounts = $manager->findIn($this->fakeRoot);
1712 1712
 		$mounts[] = $manager->find($this->fakeRoot);
@@ -1721,7 +1721,7 @@  discard block
 block discarded – undo
1721 1721
 				$cache = $mount->getStorage()->getCache();
1722 1722
 				$internalPath = $cache->getPathById($id);
1723 1723
 				if (is_string($internalPath)) {
1724
-					$fullPath = $mount->getMountPoint() . $internalPath;
1724
+					$fullPath = $mount->getMountPoint().$internalPath;
1725 1725
 					if (!is_null($path = $this->getRelativePath($fullPath))) {
1726 1726
 						return $path;
1727 1727
 					}
@@ -1764,10 +1764,10 @@  discard block
 block discarded – undo
1764 1764
 		}
1765 1765
 
1766 1766
 		// note: cannot use the view because the target is already locked
1767
-		$fileId = (int)$targetStorage->getCache()->getId($targetInternalPath);
1767
+		$fileId = (int) $targetStorage->getCache()->getId($targetInternalPath);
1768 1768
 		if ($fileId === -1) {
1769 1769
 			// target might not exist, need to check parent instead
1770
-			$fileId = (int)$targetStorage->getCache()->getId(dirname($targetInternalPath));
1770
+			$fileId = (int) $targetStorage->getCache()->getId(dirname($targetInternalPath));
1771 1771
 		}
1772 1772
 
1773 1773
 		// check if any of the parents were shared by the current owner (include collections)
@@ -1867,7 +1867,7 @@  discard block
 block discarded – undo
1867 1867
 		$resultPath = '';
1868 1868
 		foreach ($parts as $part) {
1869 1869
 			if ($part) {
1870
-				$resultPath .= '/' . $part;
1870
+				$resultPath .= '/'.$part;
1871 1871
 				$result[] = $resultPath;
1872 1872
 			}
1873 1873
 		}
@@ -2130,16 +2130,16 @@  discard block
 block discarded – undo
2130 2130
 	public function getUidAndFilename($filename) {
2131 2131
 		$info = $this->getFileInfo($filename);
2132 2132
 		if (!$info instanceof \OCP\Files\FileInfo) {
2133
-			throw new NotFoundException($this->getAbsolutePath($filename) . ' not found');
2133
+			throw new NotFoundException($this->getAbsolutePath($filename).' not found');
2134 2134
 		}
2135 2135
 		$uid = $info->getOwner()->getUID();
2136 2136
 		if ($uid != \OCP\User::getUser()) {
2137 2137
 			Filesystem::initMountPoints($uid);
2138
-			$ownerView = new View('/' . $uid . '/files');
2138
+			$ownerView = new View('/'.$uid.'/files');
2139 2139
 			try {
2140 2140
 				$filename = $ownerView->getPath($info['fileid']);
2141 2141
 			} catch (NotFoundException $e) {
2142
-				throw new NotFoundException('File with id ' . $info['fileid'] . ' not found for user ' . $uid);
2142
+				throw new NotFoundException('File with id '.$info['fileid'].' not found for user '.$uid);
2143 2143
 			}
2144 2144
 		}
2145 2145
 		return [$uid, $filename];
@@ -2156,7 +2156,7 @@  discard block
 block discarded – undo
2156 2156
 		$directoryParts = array_filter($directoryParts);
2157 2157
 		foreach ($directoryParts as $key => $part) {
2158 2158
 			$currentPathElements = array_slice($directoryParts, 0, $key);
2159
-			$currentPath = '/' . implode('/', $currentPathElements);
2159
+			$currentPath = '/'.implode('/', $currentPathElements);
2160 2160
 			if ($this->is_file($currentPath)) {
2161 2161
 				return false;
2162 2162
 			}
Please login to merge, or discard this patch.