Code Duplication    Length = 26-27 lines in 2 locations

lib/private/files/view.php 2 locations

@@ 1789-1814 (lines=26) @@
1786
	 * @return bool False if the path is excluded from locking, true otherwise
1787
	 * @throws \OCP\Lock\LockedException if the path is already locked
1788
	 */
1789
	private function lockPath($path, $type, $lockMountPoint = false) {
1790
		$absolutePath = $this->getAbsolutePath($path);
1791
		$absolutePath = Filesystem::normalizePath($absolutePath);
1792
		if (!$this->shouldLockFile($absolutePath)) {
1793
			return false;
1794
		}
1795
1796
		$mount = $this->getMountForLock($absolutePath, $lockMountPoint);
1797
		if ($mount) {
1798
			try {
1799
				$mount->getStorage()->acquireLock(
1800
					$mount->getInternalPath($absolutePath),
1801
					$type,
1802
					$this->lockingProvider
1803
				);
1804
			} catch (\OCP\Lock\LockedException $e) {
1805
				// rethrow with the a human-readable path
1806
				throw new \OCP\Lock\LockedException(
1807
					$this->getPathRelativeToFiles($absolutePath),
1808
					$e
1809
				);
1810
			}
1811
		}
1812
1813
		return true;
1814
	}
1815
1816
	/**
1817
	 * Change the lock type
@@ 1826-1852 (lines=27) @@
1823
	 * @return bool False if the path is excluded from locking, true otherwise
1824
	 * @throws \OCP\Lock\LockedException if the path is already locked
1825
	 */
1826
	public function changeLock($path, $type, $lockMountPoint = false) {
1827
		$path = Filesystem::normalizePath($path);
1828
		$absolutePath = $this->getAbsolutePath($path);
1829
		$absolutePath = Filesystem::normalizePath($absolutePath);
1830
		if (!$this->shouldLockFile($absolutePath)) {
1831
			return false;
1832
		}
1833
1834
		$mount = $this->getMountForLock($absolutePath, $lockMountPoint);
1835
		if ($mount) {
1836
			try {
1837
				$mount->getStorage()->changeLock(
1838
					$mount->getInternalPath($absolutePath),
1839
					$type,
1840
					$this->lockingProvider
1841
				);
1842
			} catch (\OCP\Lock\LockedException $e) {
1843
				// rethrow with the a human-readable path
1844
				throw new \OCP\Lock\LockedException(
1845
					$this->getPathRelativeToFiles($absolutePath),
1846
					$e
1847
				);
1848
			}
1849
		}
1850
1851
		return true;
1852
	}
1853
1854
	/**
1855
	 * Unlock the given path