Completed
Push — stable13 ( 544d28...b558e4 )
by Morris
11:19
created
lib/private/Files/View.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -126,9 +126,9 @@  discard block
 block discarded – undo
126 126
 			$path = '/';
127 127
 		}
128 128
 		if ($path[0] !== '/') {
129
-			$path = '/' . $path;
129
+			$path = '/'.$path;
130 130
 		}
131
-		return $this->fakeRoot . $path;
131
+		return $this->fakeRoot.$path;
132 132
 	}
133 133
 
134 134
 	/**
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	public function chroot($fakeRoot) {
141 141
 		if (!$fakeRoot == '') {
142 142
 			if ($fakeRoot[0] !== '/') {
143
-				$fakeRoot = '/' . $fakeRoot;
143
+				$fakeRoot = '/'.$fakeRoot;
144 144
 			}
145 145
 		}
146 146
 		$this->fakeRoot = $fakeRoot;
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 		}
173 173
 
174 174
 		// missing slashes can cause wrong matches!
175
-		$root = rtrim($this->fakeRoot, '/') . '/';
175
+		$root = rtrim($this->fakeRoot, '/').'/';
176 176
 
177 177
 		if (strpos($path, $root) !== 0) {
178 178
 			return null;
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 		if ($mount instanceof MoveableMount) {
279 279
 			// cut of /user/files to get the relative path to data/user/files
280 280
 			$pathParts = explode('/', $path, 4);
281
-			$relPath = '/' . $pathParts[3];
281
+			$relPath = '/'.$pathParts[3];
282 282
 			$this->lockFile($relPath, ILockingProvider::LOCK_SHARED, true);
283 283
 			\OC_Hook::emit(
284 284
 				Filesystem::CLASSNAME, "umount",
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
 		}
701 701
 		$postFix = (substr($path, -1, 1) === '/') ? '/' : '';
702 702
 		$absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path));
703
-		$mount = Filesystem::getMountManager()->find($absolutePath . $postFix);
703
+		$mount = Filesystem::getMountManager()->find($absolutePath.$postFix);
704 704
 		if ($mount and $mount->getInternalPath($absolutePath) === '') {
705 705
 			return $this->removeMount($mount, $absolutePath);
706 706
 		}
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
 								$this->renameUpdate($storage1, $storage2, $internalPath1, $internalPath2);
821 821
 							}
822 822
 						}
823
-					} catch(\Exception $e) {
823
+					} catch (\Exception $e) {
824 824
 						throw $e;
825 825
 					} finally {
826 826
 						$this->changeLock($path1, ILockingProvider::LOCK_SHARED, true);
@@ -844,7 +844,7 @@  discard block
 block discarded – undo
844 844
 						}
845 845
 					}
846 846
 				}
847
-			} catch(\Exception $e) {
847
+			} catch (\Exception $e) {
848 848
 				throw $e;
849 849
 			} finally {
850 850
 				$this->unlockFile($path1, ILockingProvider::LOCK_SHARED, true);
@@ -977,7 +977,7 @@  discard block
 block discarded – undo
977 977
 				$hooks[] = 'write';
978 978
 				break;
979 979
 			default:
980
-				\OCP\Util::writeLog('core', 'invalid mode (' . $mode . ') for ' . $path, \OCP\Util::ERROR);
980
+				\OCP\Util::writeLog('core', 'invalid mode ('.$mode.') for '.$path, \OCP\Util::ERROR);
981 981
 		}
982 982
 
983 983
 		if ($mode !== 'r' && $mode !== 'w') {
@@ -1081,7 +1081,7 @@  discard block
 block discarded – undo
1081 1081
 					array(Filesystem::signal_param_path => $this->getHookPath($path))
1082 1082
 				);
1083 1083
 			}
1084
-			list($storage, $internalPath) = Filesystem::resolvePath($absolutePath . $postFix);
1084
+			list($storage, $internalPath) = Filesystem::resolvePath($absolutePath.$postFix);
1085 1085
 			if ($storage) {
1086 1086
 				$result = $storage->hash($type, $internalPath, $raw);
1087 1087
 				return $result;
@@ -1136,7 +1136,7 @@  discard block
 block discarded – undo
1136 1136
 
1137 1137
 			$run = $this->runHooks($hooks, $path);
1138 1138
 			/** @var \OC\Files\Storage\Storage $storage */
1139
-			list($storage, $internalPath) = Filesystem::resolvePath($absolutePath . $postFix);
1139
+			list($storage, $internalPath) = Filesystem::resolvePath($absolutePath.$postFix);
1140 1140
 			if ($run and $storage) {
1141 1141
 				if (in_array('write', $hooks) || in_array('delete', $hooks)) {
1142 1142
 					try {
@@ -1181,7 +1181,7 @@  discard block
 block discarded – undo
1181 1181
 					$unlockLater = true;
1182 1182
 					// make sure our unlocking callback will still be called if connection is aborted
1183 1183
 					ignore_user_abort(true);
1184
-					$result = CallbackWrapper::wrap($result, null, null, function () use ($hooks, $path) {
1184
+					$result = CallbackWrapper::wrap($result, null, null, function() use ($hooks, $path) {
1185 1185
 						if (in_array('write', $hooks)) {
1186 1186
 							$this->unlockFile($path, ILockingProvider::LOCK_EXCLUSIVE);
1187 1187
 						} else if (in_array('read', $hooks)) {
@@ -1242,7 +1242,7 @@  discard block
 block discarded – undo
1242 1242
 			return true;
1243 1243
 		}
1244 1244
 
1245
-		return (strlen($fullPath) > strlen($defaultRoot)) && (substr($fullPath, 0, strlen($defaultRoot) + 1) === $defaultRoot . '/');
1245
+		return (strlen($fullPath) > strlen($defaultRoot)) && (substr($fullPath, 0, strlen($defaultRoot) + 1) === $defaultRoot.'/');
1246 1246
 	}
1247 1247
 
1248 1248
 	/**
@@ -1261,7 +1261,7 @@  discard block
 block discarded – undo
1261 1261
 				if ($hook != 'read') {
1262 1262
 					\OC_Hook::emit(
1263 1263
 						Filesystem::CLASSNAME,
1264
-						$prefix . $hook,
1264
+						$prefix.$hook,
1265 1265
 						array(
1266 1266
 							Filesystem::signal_param_run => &$run,
1267 1267
 							Filesystem::signal_param_path => $path
@@ -1270,7 +1270,7 @@  discard block
 block discarded – undo
1270 1270
 				} elseif (!$post) {
1271 1271
 					\OC_Hook::emit(
1272 1272
 						Filesystem::CLASSNAME,
1273
-						$prefix . $hook,
1273
+						$prefix.$hook,
1274 1274
 						array(
1275 1275
 							Filesystem::signal_param_path => $path
1276 1276
 						)
@@ -1363,7 +1363,7 @@  discard block
 block discarded – undo
1363 1363
 			return $this->getPartFileInfo($path);
1364 1364
 		}
1365 1365
 		$relativePath = $path;
1366
-		$path = Filesystem::normalizePath($this->fakeRoot . '/' . $path);
1366
+		$path = Filesystem::normalizePath($this->fakeRoot.'/'.$path);
1367 1367
 
1368 1368
 		$mount = Filesystem::getMountManager()->find($path);
1369 1369
 		if (!$mount) {
@@ -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
 					}));
@@ -1444,12 +1444,12 @@  discard block
 block discarded – undo
1444 1444
 			/**
1445 1445
 			 * @var \OC\Files\FileInfo[] $fileInfos
1446 1446
 			 */
1447
-			$fileInfos = array_map(function (ICacheEntry $content) use ($path, $storage, $mount, $sharingDisabled) {
1447
+			$fileInfos = array_map(function(ICacheEntry $content) use ($path, $storage, $mount, $sharingDisabled) {
1448 1448
 				if ($sharingDisabled) {
1449 1449
 					$content['permissions'] = $content['permissions'] & ~\OCP\Constants::PERMISSION_SHARE;
1450 1450
 				}
1451 1451
 				$owner = $this->getUserObjectForOwner($storage->getOwner($content['path']));
1452
-				return new FileInfo($path . '/' . $content['name'], $storage, $content['path'], $content, $mount, $owner);
1452
+				return new FileInfo($path.'/'.$content['name'], $storage, $content['path'], $content, $mount, $owner);
1453 1453
 			}, $contents);
1454 1454
 			$files = array_combine($fileNames, $fileInfos);
1455 1455
 
@@ -1475,8 +1475,8 @@  discard block
 block discarded – undo
1475 1475
 							// sometimes when the storage is not available it can be any exception
1476 1476
 							\OCP\Util::writeLog(
1477 1477
 								'core',
1478
-								'Exception while scanning storage "' . $subStorage->getId() . '": ' .
1479
-								get_class($e) . ': ' . $e->getMessage(),
1478
+								'Exception while scanning storage "'.$subStorage->getId().'": '.
1479
+								get_class($e).': '.$e->getMessage(),
1480 1480
 								\OCP\Util::ERROR
1481 1481
 							);
1482 1482
 							continue;
@@ -1506,7 +1506,7 @@  discard block
 block discarded – undo
1506 1506
 								$rootEntry['permissions'] = $permissions & (\OCP\Constants::PERMISSION_ALL - (\OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE));
1507 1507
 							}
1508 1508
 
1509
-							$rootEntry['path'] = substr(Filesystem::normalizePath($path . '/' . $rootEntry['name']), strlen($user) + 2); // full path without /$user/
1509
+							$rootEntry['path'] = substr(Filesystem::normalizePath($path.'/'.$rootEntry['name']), strlen($user) + 2); // full path without /$user/
1510 1510
 
1511 1511
 							// if sharing was disabled for the user we remove the share permissions
1512 1512
 							if (\OCP\Util::isSharingDisabledForUser()) {
@@ -1514,14 +1514,14 @@  discard block
 block discarded – undo
1514 1514
 							}
1515 1515
 
1516 1516
 							$owner = $this->getUserObjectForOwner($subStorage->getOwner(''));
1517
-							$files[$rootEntry->getName()] = new FileInfo($path . '/' . $rootEntry['name'], $subStorage, '', $rootEntry, $mount, $owner);
1517
+							$files[$rootEntry->getName()] = new FileInfo($path.'/'.$rootEntry['name'], $subStorage, '', $rootEntry, $mount, $owner);
1518 1518
 						}
1519 1519
 					}
1520 1520
 				}
1521 1521
 			}
1522 1522
 
1523 1523
 			if ($mimetype_filter) {
1524
-				$files = array_filter($files, function (FileInfo $file) use ($mimetype_filter) {
1524
+				$files = array_filter($files, function(FileInfo $file) use ($mimetype_filter) {
1525 1525
 					if (strpos($mimetype_filter, '/')) {
1526 1526
 						return $file->getMimetype() === $mimetype_filter;
1527 1527
 					} else {
@@ -1550,7 +1550,7 @@  discard block
 block discarded – undo
1550 1550
 		if ($data instanceof FileInfo) {
1551 1551
 			$data = $data->getData();
1552 1552
 		}
1553
-		$path = Filesystem::normalizePath($this->fakeRoot . '/' . $path);
1553
+		$path = Filesystem::normalizePath($this->fakeRoot.'/'.$path);
1554 1554
 		/**
1555 1555
 		 * @var \OC\Files\Storage\Storage $storage
1556 1556
 		 * @var string $internalPath
@@ -1577,7 +1577,7 @@  discard block
 block discarded – undo
1577 1577
 	 * @return FileInfo[]
1578 1578
 	 */
1579 1579
 	public function search($query) {
1580
-		return $this->searchCommon('search', array('%' . $query . '%'));
1580
+		return $this->searchCommon('search', array('%'.$query.'%'));
1581 1581
 	}
1582 1582
 
1583 1583
 	/**
@@ -1628,10 +1628,10 @@  discard block
 block discarded – undo
1628 1628
 
1629 1629
 			$results = call_user_func_array(array($cache, $method), $args);
1630 1630
 			foreach ($results as $result) {
1631
-				if (substr($mountPoint . $result['path'], 0, $rootLength + 1) === $this->fakeRoot . '/') {
1631
+				if (substr($mountPoint.$result['path'], 0, $rootLength + 1) === $this->fakeRoot.'/') {
1632 1632
 					$internalPath = $result['path'];
1633
-					$path = $mountPoint . $result['path'];
1634
-					$result['path'] = substr($mountPoint . $result['path'], $rootLength);
1633
+					$path = $mountPoint.$result['path'];
1634
+					$result['path'] = substr($mountPoint.$result['path'], $rootLength);
1635 1635
 					$owner = \OC::$server->getUserManager()->get($storage->getOwner($internalPath));
1636 1636
 					$files[] = new FileInfo($path, $storage, $internalPath, $result, $mount, $owner);
1637 1637
 				}
@@ -1649,8 +1649,8 @@  discard block
 block discarded – undo
1649 1649
 					if ($results) {
1650 1650
 						foreach ($results as $result) {
1651 1651
 							$internalPath = $result['path'];
1652
-							$result['path'] = rtrim($relativeMountPoint . $result['path'], '/');
1653
-							$path = rtrim($mountPoint . $internalPath, '/');
1652
+							$result['path'] = rtrim($relativeMountPoint.$result['path'], '/');
1653
+							$path = rtrim($mountPoint.$internalPath, '/');
1654 1654
 							$owner = \OC::$server->getUserManager()->get($storage->getOwner($internalPath));
1655 1655
 							$files[] = new FileInfo($path, $storage, $internalPath, $result, $mount, $owner);
1656 1656
 						}
@@ -1671,7 +1671,7 @@  discard block
 block discarded – undo
1671 1671
 	public function getOwner($path) {
1672 1672
 		$info = $this->getFileInfo($path);
1673 1673
 		if (!$info) {
1674
-			throw new NotFoundException($path . ' not found while trying to get owner');
1674
+			throw new NotFoundException($path.' not found while trying to get owner');
1675 1675
 		}
1676 1676
 		return $info->getOwner()->getUID();
1677 1677
 	}
@@ -1705,7 +1705,7 @@  discard block
 block discarded – undo
1705 1705
 	 * @return string
1706 1706
 	 */
1707 1707
 	public function getPath($id) {
1708
-		$id = (int)$id;
1708
+		$id = (int) $id;
1709 1709
 		$manager = Filesystem::getMountManager();
1710 1710
 		$mounts = $manager->findIn($this->fakeRoot);
1711 1711
 		$mounts[] = $manager->find($this->fakeRoot);
@@ -1720,7 +1720,7 @@  discard block
 block discarded – undo
1720 1720
 				$cache = $mount->getStorage()->getCache();
1721 1721
 				$internalPath = $cache->getPathById($id);
1722 1722
 				if (is_string($internalPath)) {
1723
-					$fullPath = $mount->getMountPoint() . $internalPath;
1723
+					$fullPath = $mount->getMountPoint().$internalPath;
1724 1724
 					if (!is_null($path = $this->getRelativePath($fullPath))) {
1725 1725
 						return $path;
1726 1726
 					}
@@ -1763,10 +1763,10 @@  discard block
 block discarded – undo
1763 1763
 		}
1764 1764
 
1765 1765
 		// note: cannot use the view because the target is already locked
1766
-		$fileId = (int)$targetStorage->getCache()->getId($targetInternalPath);
1766
+		$fileId = (int) $targetStorage->getCache()->getId($targetInternalPath);
1767 1767
 		if ($fileId === -1) {
1768 1768
 			// target might not exist, need to check parent instead
1769
-			$fileId = (int)$targetStorage->getCache()->getId(dirname($targetInternalPath));
1769
+			$fileId = (int) $targetStorage->getCache()->getId(dirname($targetInternalPath));
1770 1770
 		}
1771 1771
 
1772 1772
 		// check if any of the parents were shared by the current owner (include collections)
@@ -1866,7 +1866,7 @@  discard block
 block discarded – undo
1866 1866
 		$resultPath = '';
1867 1867
 		foreach ($parts as $part) {
1868 1868
 			if ($part) {
1869
-				$resultPath .= '/' . $part;
1869
+				$resultPath .= '/'.$part;
1870 1870
 				$result[] = $resultPath;
1871 1871
 			}
1872 1872
 		}
@@ -2129,16 +2129,16 @@  discard block
 block discarded – undo
2129 2129
 	public function getUidAndFilename($filename) {
2130 2130
 		$info = $this->getFileInfo($filename);
2131 2131
 		if (!$info instanceof \OCP\Files\FileInfo) {
2132
-			throw new NotFoundException($this->getAbsolutePath($filename) . ' not found');
2132
+			throw new NotFoundException($this->getAbsolutePath($filename).' not found');
2133 2133
 		}
2134 2134
 		$uid = $info->getOwner()->getUID();
2135 2135
 		if ($uid != \OCP\User::getUser()) {
2136 2136
 			Filesystem::initMountPoints($uid);
2137
-			$ownerView = new View('/' . $uid . '/files');
2137
+			$ownerView = new View('/'.$uid.'/files');
2138 2138
 			try {
2139 2139
 				$filename = $ownerView->getPath($info['fileid']);
2140 2140
 			} catch (NotFoundException $e) {
2141
-				throw new NotFoundException('File with id ' . $info['fileid'] . ' not found for user ' . $uid);
2141
+				throw new NotFoundException('File with id '.$info['fileid'].' not found for user '.$uid);
2142 2142
 			}
2143 2143
 		}
2144 2144
 		return [$uid, $filename];
@@ -2155,7 +2155,7 @@  discard block
 block discarded – undo
2155 2155
 		$directoryParts = array_filter($directoryParts);
2156 2156
 		foreach ($directoryParts as $key => $part) {
2157 2157
 			$currentPathElements = array_slice($directoryParts, 0, $key);
2158
-			$currentPath = '/' . implode('/', $currentPathElements);
2158
+			$currentPath = '/'.implode('/', $currentPathElements);
2159 2159
 			if ($this->is_file($currentPath)) {
2160 2160
 				return false;
2161 2161
 			}
Please login to merge, or discard this patch.