Passed
Push — master ( e80866...ecc806 )
by Morris
19:26 queued 09:48
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
 					$this->changeLock($path, ILockingProvider::LOCK_EXCLUSIVE);
@@ -1157,7 +1157,7 @@  discard block
 block discarded – undo
1157 1157
 				if ($result && in_array('delete', $hooks) and $result) {
1158 1158
 					$this->removeUpdate($storage, $internalPath);
1159 1159
 				}
1160
-				if ($result && in_array('write', $hooks,  true) && $operation !== 'fopen' && $operation !== 'touch') {
1160
+				if ($result && in_array('write', $hooks, true) && $operation !== 'fopen' && $operation !== 'touch') {
1161 1161
 					$this->writeUpdate($storage, $internalPath);
1162 1162
 				}
1163 1163
 				if ($result && in_array('touch', $hooks)) {
@@ -1173,7 +1173,7 @@  discard block
 block discarded – undo
1173 1173
 					$unlockLater = true;
1174 1174
 					// make sure our unlocking callback will still be called if connection is aborted
1175 1175
 					ignore_user_abort(true);
1176
-					$result = CallbackWrapper::wrap($result, null, null, function () use ($hooks, $path) {
1176
+					$result = CallbackWrapper::wrap($result, null, null, function() use ($hooks, $path) {
1177 1177
 						if (in_array('write', $hooks)) {
1178 1178
 							$this->unlockFile($path, ILockingProvider::LOCK_EXCLUSIVE);
1179 1179
 						} else if (in_array('read', $hooks)) {
@@ -1234,7 +1234,7 @@  discard block
 block discarded – undo
1234 1234
 			return true;
1235 1235
 		}
1236 1236
 
1237
-		return (strlen($fullPath) > strlen($defaultRoot)) && (substr($fullPath, 0, strlen($defaultRoot) + 1) === $defaultRoot . '/');
1237
+		return (strlen($fullPath) > strlen($defaultRoot)) && (substr($fullPath, 0, strlen($defaultRoot) + 1) === $defaultRoot.'/');
1238 1238
 	}
1239 1239
 
1240 1240
 	/**
@@ -1253,7 +1253,7 @@  discard block
 block discarded – undo
1253 1253
 				if ($hook != 'read') {
1254 1254
 					\OC_Hook::emit(
1255 1255
 						Filesystem::CLASSNAME,
1256
-						$prefix . $hook,
1256
+						$prefix.$hook,
1257 1257
 						array(
1258 1258
 							Filesystem::signal_param_run => &$run,
1259 1259
 							Filesystem::signal_param_path => $path
@@ -1262,7 +1262,7 @@  discard block
 block discarded – undo
1262 1262
 				} elseif (!$post) {
1263 1263
 					\OC_Hook::emit(
1264 1264
 						Filesystem::CLASSNAME,
1265
-						$prefix . $hook,
1265
+						$prefix.$hook,
1266 1266
 						array(
1267 1267
 							Filesystem::signal_param_path => $path
1268 1268
 						)
@@ -1355,11 +1355,11 @@  discard block
 block discarded – undo
1355 1355
 			return $this->getPartFileInfo($path);
1356 1356
 		}
1357 1357
 		$relativePath = $path;
1358
-		$path = Filesystem::normalizePath($this->fakeRoot . '/' . $path);
1358
+		$path = Filesystem::normalizePath($this->fakeRoot.'/'.$path);
1359 1359
 
1360 1360
 		$mount = Filesystem::getMountManager()->find($path);
1361 1361
 		if (!$mount) {
1362
-			\OC::$server->getLogger()->warning('Mountpoint not found for path: ' . $path);
1362
+			\OC::$server->getLogger()->warning('Mountpoint not found for path: '.$path);
1363 1363
 			return false;
1364 1364
 		}
1365 1365
 		$storage = $mount->getStorage();
@@ -1368,7 +1368,7 @@  discard block
 block discarded – undo
1368 1368
 			$data = $this->getCacheEntry($storage, $internalPath, $relativePath);
1369 1369
 
1370 1370
 			if (!$data instanceof ICacheEntry) {
1371
-				\OC::$server->getLogger()->debug('No cache entry found for ' . $path . ' (storage: ' . $storage->getId() . ', internalPath: ' . $internalPath . ')');
1371
+				\OC::$server->getLogger()->debug('No cache entry found for '.$path.' (storage: '.$storage->getId().', internalPath: '.$internalPath.')');
1372 1372
 				return false;
1373 1373
 			}
1374 1374
 
@@ -1384,7 +1384,7 @@  discard block
 block discarded – undo
1384 1384
 					//add the sizes of other mount points to the folder
1385 1385
 					$extOnly = ($includeMountPoints === 'ext');
1386 1386
 					$mounts = Filesystem::getMountManager()->findIn($path);
1387
-					$info->setSubMounts(array_filter($mounts, function (IMountPoint $mount) use ($extOnly) {
1387
+					$info->setSubMounts(array_filter($mounts, function(IMountPoint $mount) use ($extOnly) {
1388 1388
 						$subStorage = $mount->getStorage();
1389 1389
 						return !($extOnly && $subStorage instanceof \OCA\Files_Sharing\SharedStorage);
1390 1390
 					}));
@@ -1393,7 +1393,7 @@  discard block
 block discarded – undo
1393 1393
 
1394 1394
 			return $info;
1395 1395
 		} else {
1396
-			\OC::$server->getLogger()->warning('Storage not valid for mountpoint: ' . $mount->getMountPoint());
1396
+			\OC::$server->getLogger()->warning('Storage not valid for mountpoint: '.$mount->getMountPoint());
1397 1397
 		}
1398 1398
 
1399 1399
 		return false;
@@ -1440,12 +1440,12 @@  discard block
 block discarded – undo
1440 1440
 			/**
1441 1441
 			 * @var \OC\Files\FileInfo[] $fileInfos
1442 1442
 			 */
1443
-			$fileInfos = array_map(function (ICacheEntry $content) use ($path, $storage, $mount, $sharingDisabled) {
1443
+			$fileInfos = array_map(function(ICacheEntry $content) use ($path, $storage, $mount, $sharingDisabled) {
1444 1444
 				if ($sharingDisabled) {
1445 1445
 					$content['permissions'] = $content['permissions'] & ~\OCP\Constants::PERMISSION_SHARE;
1446 1446
 				}
1447 1447
 				$owner = $this->getUserObjectForOwner($storage->getOwner($content['path']));
1448
-				return new FileInfo($path . '/' . $content['name'], $storage, $content['path'], $content, $mount, $owner);
1448
+				return new FileInfo($path.'/'.$content['name'], $storage, $content['path'], $content, $mount, $owner);
1449 1449
 			}, $contents);
1450 1450
 			$files = array_combine($fileNames, $fileInfos);
1451 1451
 
@@ -1470,7 +1470,7 @@  discard block
 block discarded – undo
1470 1470
 						} catch (\Exception $e) {
1471 1471
 							// sometimes when the storage is not available it can be any exception
1472 1472
 							\OC::$server->getLogger()->logException($e, [
1473
-								'message' => 'Exception while scanning storage "' . $subStorage->getId() . '"',
1473
+								'message' => 'Exception while scanning storage "'.$subStorage->getId().'"',
1474 1474
 								'level' => ILogger::ERROR,
1475 1475
 								'app' => 'lib',
1476 1476
 							]);
@@ -1501,7 +1501,7 @@  discard block
 block discarded – undo
1501 1501
 								$rootEntry['permissions'] = $permissions & (\OCP\Constants::PERMISSION_ALL - (\OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_DELETE));
1502 1502
 							}
1503 1503
 
1504
-							$rootEntry['path'] = substr(Filesystem::normalizePath($path . '/' . $rootEntry['name']), strlen($user) + 2); // full path without /$user/
1504
+							$rootEntry['path'] = substr(Filesystem::normalizePath($path.'/'.$rootEntry['name']), strlen($user) + 2); // full path without /$user/
1505 1505
 
1506 1506
 							// if sharing was disabled for the user we remove the share permissions
1507 1507
 							if (\OCP\Util::isSharingDisabledForUser()) {
@@ -1509,14 +1509,14 @@  discard block
 block discarded – undo
1509 1509
 							}
1510 1510
 
1511 1511
 							$owner = $this->getUserObjectForOwner($subStorage->getOwner(''));
1512
-							$files[$rootEntry->getName()] = new FileInfo($path . '/' . $rootEntry['name'], $subStorage, '', $rootEntry, $mount, $owner);
1512
+							$files[$rootEntry->getName()] = new FileInfo($path.'/'.$rootEntry['name'], $subStorage, '', $rootEntry, $mount, $owner);
1513 1513
 						}
1514 1514
 					}
1515 1515
 				}
1516 1516
 			}
1517 1517
 
1518 1518
 			if ($mimetype_filter) {
1519
-				$files = array_filter($files, function (FileInfo $file) use ($mimetype_filter) {
1519
+				$files = array_filter($files, function(FileInfo $file) use ($mimetype_filter) {
1520 1520
 					if (strpos($mimetype_filter, '/')) {
1521 1521
 						return $file->getMimetype() === $mimetype_filter;
1522 1522
 					} else {
@@ -1545,7 +1545,7 @@  discard block
 block discarded – undo
1545 1545
 		if ($data instanceof FileInfo) {
1546 1546
 			$data = $data->getData();
1547 1547
 		}
1548
-		$path = Filesystem::normalizePath($this->fakeRoot . '/' . $path);
1548
+		$path = Filesystem::normalizePath($this->fakeRoot.'/'.$path);
1549 1549
 		/**
1550 1550
 		 * @var \OC\Files\Storage\Storage $storage
1551 1551
 		 * @var string $internalPath
@@ -1572,7 +1572,7 @@  discard block
 block discarded – undo
1572 1572
 	 * @return FileInfo[]
1573 1573
 	 */
1574 1574
 	public function search($query) {
1575
-		return $this->searchCommon('search', array('%' . $query . '%'));
1575
+		return $this->searchCommon('search', array('%'.$query.'%'));
1576 1576
 	}
1577 1577
 
1578 1578
 	/**
@@ -1623,10 +1623,10 @@  discard block
 block discarded – undo
1623 1623
 
1624 1624
 			$results = call_user_func_array(array($cache, $method), $args);
1625 1625
 			foreach ($results as $result) {
1626
-				if (substr($mountPoint . $result['path'], 0, $rootLength + 1) === $this->fakeRoot . '/') {
1626
+				if (substr($mountPoint.$result['path'], 0, $rootLength + 1) === $this->fakeRoot.'/') {
1627 1627
 					$internalPath = $result['path'];
1628
-					$path = $mountPoint . $result['path'];
1629
-					$result['path'] = substr($mountPoint . $result['path'], $rootLength);
1628
+					$path = $mountPoint.$result['path'];
1629
+					$result['path'] = substr($mountPoint.$result['path'], $rootLength);
1630 1630
 					$owner = \OC::$server->getUserManager()->get($storage->getOwner($internalPath));
1631 1631
 					$files[] = new FileInfo($path, $storage, $internalPath, $result, $mount, $owner);
1632 1632
 				}
@@ -1644,8 +1644,8 @@  discard block
 block discarded – undo
1644 1644
 					if ($results) {
1645 1645
 						foreach ($results as $result) {
1646 1646
 							$internalPath = $result['path'];
1647
-							$result['path'] = rtrim($relativeMountPoint . $result['path'], '/');
1648
-							$path = rtrim($mountPoint . $internalPath, '/');
1647
+							$result['path'] = rtrim($relativeMountPoint.$result['path'], '/');
1648
+							$path = rtrim($mountPoint.$internalPath, '/');
1649 1649
 							$owner = \OC::$server->getUserManager()->get($storage->getOwner($internalPath));
1650 1650
 							$files[] = new FileInfo($path, $storage, $internalPath, $result, $mount, $owner);
1651 1651
 						}
@@ -1666,7 +1666,7 @@  discard block
 block discarded – undo
1666 1666
 	public function getOwner($path) {
1667 1667
 		$info = $this->getFileInfo($path);
1668 1668
 		if (!$info) {
1669
-			throw new NotFoundException($path . ' not found while trying to get owner');
1669
+			throw new NotFoundException($path.' not found while trying to get owner');
1670 1670
 		}
1671 1671
 		return $info->getOwner()->getUID();
1672 1672
 	}
@@ -1700,7 +1700,7 @@  discard block
 block discarded – undo
1700 1700
 	 * @return string
1701 1701
 	 */
1702 1702
 	public function getPath($id) {
1703
-		$id = (int)$id;
1703
+		$id = (int) $id;
1704 1704
 		$manager = Filesystem::getMountManager();
1705 1705
 		$mounts = $manager->findIn($this->fakeRoot);
1706 1706
 		$mounts[] = $manager->find($this->fakeRoot);
@@ -1715,7 +1715,7 @@  discard block
 block discarded – undo
1715 1715
 				$cache = $mount->getStorage()->getCache();
1716 1716
 				$internalPath = $cache->getPathById($id);
1717 1717
 				if (is_string($internalPath)) {
1718
-					$fullPath = $mount->getMountPoint() . $internalPath;
1718
+					$fullPath = $mount->getMountPoint().$internalPath;
1719 1719
 					if (!is_null($path = $this->getRelativePath($fullPath))) {
1720 1720
 						return $path;
1721 1721
 					}
@@ -1758,10 +1758,10 @@  discard block
 block discarded – undo
1758 1758
 		}
1759 1759
 
1760 1760
 		// note: cannot use the view because the target is already locked
1761
-		$fileId = (int)$targetStorage->getCache()->getId($targetInternalPath);
1761
+		$fileId = (int) $targetStorage->getCache()->getId($targetInternalPath);
1762 1762
 		if ($fileId === -1) {
1763 1763
 			// target might not exist, need to check parent instead
1764
-			$fileId = (int)$targetStorage->getCache()->getId(dirname($targetInternalPath));
1764
+			$fileId = (int) $targetStorage->getCache()->getId(dirname($targetInternalPath));
1765 1765
 		}
1766 1766
 
1767 1767
 		// check if any of the parents were shared by the current owner (include collections)
@@ -1861,7 +1861,7 @@  discard block
 block discarded – undo
1861 1861
 		$resultPath = '';
1862 1862
 		foreach ($parts as $part) {
1863 1863
 			if ($part) {
1864
-				$resultPath .= '/' . $part;
1864
+				$resultPath .= '/'.$part;
1865 1865
 				$result[] = $resultPath;
1866 1866
 			}
1867 1867
 		}
@@ -2124,16 +2124,16 @@  discard block
 block discarded – undo
2124 2124
 	public function getUidAndFilename($filename) {
2125 2125
 		$info = $this->getFileInfo($filename);
2126 2126
 		if (!$info instanceof \OCP\Files\FileInfo) {
2127
-			throw new NotFoundException($this->getAbsolutePath($filename) . ' not found');
2127
+			throw new NotFoundException($this->getAbsolutePath($filename).' not found');
2128 2128
 		}
2129 2129
 		$uid = $info->getOwner()->getUID();
2130 2130
 		if ($uid != \OCP\User::getUser()) {
2131 2131
 			Filesystem::initMountPoints($uid);
2132
-			$ownerView = new View('/' . $uid . '/files');
2132
+			$ownerView = new View('/'.$uid.'/files');
2133 2133
 			try {
2134 2134
 				$filename = $ownerView->getPath($info['fileid']);
2135 2135
 			} catch (NotFoundException $e) {
2136
-				throw new NotFoundException('File with id ' . $info['fileid'] . ' not found for user ' . $uid);
2136
+				throw new NotFoundException('File with id '.$info['fileid'].' not found for user '.$uid);
2137 2137
 			}
2138 2138
 		}
2139 2139
 		return [$uid, $filename];
@@ -2150,7 +2150,7 @@  discard block
 block discarded – undo
2150 2150
 		$directoryParts = array_filter($directoryParts);
2151 2151
 		foreach ($directoryParts as $key => $part) {
2152 2152
 			$currentPathElements = array_slice($directoryParts, 0, $key);
2153
-			$currentPath = '/' . implode('/', $currentPathElements);
2153
+			$currentPath = '/'.implode('/', $currentPathElements);
2154 2154
 			if ($this->is_file($currentPath)) {
2155 2155
 				return false;
2156 2156
 			}
Please login to merge, or discard this patch.