Code Duplication    Length = 29-30 lines in 2 locations

lib/private/Files/View.php 2 locations

@@ 1875-1903 (lines=29) @@
1872
	 * @return bool False if the path is excluded from locking, true otherwise
1873
	 * @throws \OCP\Lock\LockedException if the path is already locked
1874
	 */
1875
	private function lockPath($path, $type, $lockMountPoint = false) {
1876
		$absolutePath = $this->getAbsolutePath($path);
1877
		$absolutePath = Filesystem::normalizePath($absolutePath);
1878
		if (!$this->shouldLockFile($absolutePath)) {
1879
			return false;
1880
		}
1881
1882
		$mount = $this->getMountForLock($absolutePath, $lockMountPoint);
1883
		if ($mount) {
1884
			try {
1885
				$storage = $mount->getStorage();
1886
				if ($storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
1887
					$storage->acquireLock(
1888
						$mount->getInternalPath($absolutePath),
1889
						$type,
1890
						$this->lockingProvider
1891
					);
1892
				}
1893
			} catch (\OCP\Lock\LockedException $e) {
1894
				// rethrow with the a human-readable path
1895
				throw new \OCP\Lock\LockedException(
1896
					$this->getPathRelativeToFiles($absolutePath),
1897
					$e
1898
				);
1899
			}
1900
		}
1901
1902
		return true;
1903
	}
1904
1905
	/**
1906
	 * Change the lock type
@@ 1915-1944 (lines=30) @@
1912
	 * @return bool False if the path is excluded from locking, true otherwise
1913
	 * @throws \OCP\Lock\LockedException if the path is already locked
1914
	 */
1915
	public function changeLock($path, $type, $lockMountPoint = false) {
1916
		$path = Filesystem::normalizePath($path);
1917
		$absolutePath = $this->getAbsolutePath($path);
1918
		$absolutePath = Filesystem::normalizePath($absolutePath);
1919
		if (!$this->shouldLockFile($absolutePath)) {
1920
			return false;
1921
		}
1922
1923
		$mount = $this->getMountForLock($absolutePath, $lockMountPoint);
1924
		if ($mount) {
1925
			try {
1926
				$storage = $mount->getStorage();
1927
				if ($storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
1928
					$storage->changeLock(
1929
						$mount->getInternalPath($absolutePath),
1930
						$type,
1931
						$this->lockingProvider
1932
					);
1933
				}
1934
			} catch (\OCP\Lock\LockedException $e) {
1935
				// rethrow with the a human-readable path
1936
				throw new \OCP\Lock\LockedException(
1937
					$this->getPathRelativeToFiles($absolutePath),
1938
					$e
1939
				);
1940
			}
1941
		}
1942
1943
		return true;
1944
	}
1945
1946
	/**
1947
	 * Unlock the given path