Code Duplication    Length = 26-27 lines in 2 locations

lib/private/files/view.php 2 locations

@@ 1828-1853 (lines=26) @@
1825
	 * @return bool False if the path is excluded from locking, true otherwise
1826
	 * @throws \OCP\Lock\LockedException if the path is already locked
1827
	 */
1828
	private function lockPath($path, $type, $lockMountPoint = false) {
1829
		$absolutePath = $this->getAbsolutePath($path);
1830
		$absolutePath = Filesystem::normalizePath($absolutePath);
1831
		if (!$this->shouldLockFile($absolutePath)) {
1832
			return false;
1833
		}
1834
1835
		$mount = $this->getMountForLock($absolutePath, $lockMountPoint);
1836
		if ($mount) {
1837
			try {
1838
				$mount->getStorage()->acquireLock(
1839
					$mount->getInternalPath($absolutePath),
1840
					$type,
1841
					$this->lockingProvider
1842
				);
1843
			} catch (\OCP\Lock\LockedException $e) {
1844
				// rethrow with the a human-readable path
1845
				throw new \OCP\Lock\LockedException(
1846
					$this->getPathRelativeToFiles($absolutePath),
1847
					$e
1848
				);
1849
			}
1850
		}
1851
1852
		return true;
1853
	}
1854
1855
	/**
1856
	 * Change the lock type
@@ 1865-1891 (lines=27) @@
1862
	 * @return bool False if the path is excluded from locking, true otherwise
1863
	 * @throws \OCP\Lock\LockedException if the path is already locked
1864
	 */
1865
	public function changeLock($path, $type, $lockMountPoint = false) {
1866
		$path = Filesystem::normalizePath($path);
1867
		$absolutePath = $this->getAbsolutePath($path);
1868
		$absolutePath = Filesystem::normalizePath($absolutePath);
1869
		if (!$this->shouldLockFile($absolutePath)) {
1870
			return false;
1871
		}
1872
1873
		$mount = $this->getMountForLock($absolutePath, $lockMountPoint);
1874
		if ($mount) {
1875
			try {
1876
				$mount->getStorage()->changeLock(
1877
					$mount->getInternalPath($absolutePath),
1878
					$type,
1879
					$this->lockingProvider
1880
				);
1881
			} catch (\OCP\Lock\LockedException $e) {
1882
				// rethrow with the a human-readable path
1883
				throw new \OCP\Lock\LockedException(
1884
					$this->getPathRelativeToFiles($absolutePath),
1885
					$e
1886
				);
1887
			}
1888
		}
1889
1890
		return true;
1891
	}
1892
1893
	/**
1894
	 * Unlock the given path