Code Duplication    Length = 29-30 lines in 2 locations

lib/private/Files/View.php 2 locations

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