Code Duplication    Length = 29-30 lines in 2 locations

lib/private/Files/View.php 2 locations

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