Code Duplication    Length = 29-30 lines in 2 locations

lib/private/Files/View.php 2 locations

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