Code Duplication    Length = 29-30 lines in 2 locations

lib/private/Files/View.php 2 locations

@@ 1893-1921 (lines=29) @@
1890
	 * @return bool False if the path is excluded from locking, true otherwise
1891
	 * @throws \OCP\Lock\LockedException if the path is already locked
1892
	 */
1893
	private function lockPath($path, $type, $lockMountPoint = false) {
1894
		$absolutePath = $this->getAbsolutePath($path);
1895
		$absolutePath = Filesystem::normalizePath($absolutePath);
1896
		if (!$this->shouldLockFile($absolutePath)) {
1897
			return false;
1898
		}
1899
1900
		$mount = $this->getMountForLock($absolutePath, $lockMountPoint);
1901
		if ($mount) {
1902
			try {
1903
				$storage = $mount->getStorage();
1904
				if ($storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
1905
					$storage->acquireLock(
1906
						$mount->getInternalPath($absolutePath),
1907
						$type,
1908
						$this->lockingProvider
1909
					);
1910
				}
1911
			} catch (\OCP\Lock\LockedException $e) {
1912
				// rethrow with the a human-readable path
1913
				throw new \OCP\Lock\LockedException(
1914
					$this->getPathRelativeToFiles($absolutePath),
1915
					$e
1916
				);
1917
			}
1918
		}
1919
1920
		return true;
1921
	}
1922
1923
	/**
1924
	 * Change the lock type
@@ 1933-1962 (lines=30) @@
1930
	 * @return bool False if the path is excluded from locking, true otherwise
1931
	 * @throws \OCP\Lock\LockedException if the path is already locked
1932
	 */
1933
	public function changeLock($path, $type, $lockMountPoint = false) {
1934
		$path = Filesystem::normalizePath($path);
1935
		$absolutePath = $this->getAbsolutePath($path);
1936
		$absolutePath = Filesystem::normalizePath($absolutePath);
1937
		if (!$this->shouldLockFile($absolutePath)) {
1938
			return false;
1939
		}
1940
1941
		$mount = $this->getMountForLock($absolutePath, $lockMountPoint);
1942
		if ($mount) {
1943
			try {
1944
				$storage = $mount->getStorage();
1945
				if ($storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
1946
					$storage->changeLock(
1947
						$mount->getInternalPath($absolutePath),
1948
						$type,
1949
						$this->lockingProvider
1950
					);
1951
				}
1952
			} catch (\OCP\Lock\LockedException $e) {
1953
				// rethrow with the a human-readable path
1954
				throw new \OCP\Lock\LockedException(
1955
					$this->getPathRelativeToFiles($absolutePath),
1956
					$e
1957
				);
1958
			}
1959
		}
1960
1961
		return true;
1962
	}
1963
1964
	/**
1965
	 * Unlock the given path