Code Duplication    Length = 29-30 lines in 2 locations

lib/private/Files/View.php 2 locations

@@ 1935-1963 (lines=29) @@
1932
	 * @return bool False if the path is excluded from locking, true otherwise
1933
	 * @throws \OCP\Lock\LockedException if the path is already locked
1934
	 */
1935
	private function lockPath($path, $type, $lockMountPoint = false) {
1936
		$absolutePath = $this->getAbsolutePath($path);
1937
		$absolutePath = Filesystem::normalizePath($absolutePath);
1938
		if (!$this->shouldLockFile($absolutePath)) {
1939
			return false;
1940
		}
1941
1942
		$mount = $this->getMountForLock($absolutePath, $lockMountPoint);
1943
		if ($mount) {
1944
			try {
1945
				$storage = $mount->getStorage();
1946
				if ($storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
1947
					$storage->acquireLock(
1948
						$mount->getInternalPath($absolutePath),
1949
						$type,
1950
						$this->lockingProvider
1951
					);
1952
				}
1953
			} catch (\OCP\Lock\LockedException $e) {
1954
				// rethrow with the a human-readable path
1955
				throw new \OCP\Lock\LockedException(
1956
					$this->getPathRelativeToFiles($absolutePath),
1957
					$e
1958
				);
1959
			}
1960
		}
1961
1962
		return true;
1963
	}
1964
1965
	/**
1966
	 * Change the lock type
@@ 1975-2004 (lines=30) @@
1972
	 * @return bool False if the path is excluded from locking, true otherwise
1973
	 * @throws \OCP\Lock\LockedException if the path is already locked
1974
	 */
1975
	public function changeLock($path, $type, $lockMountPoint = false) {
1976
		$path = Filesystem::normalizePath($path);
1977
		$absolutePath = $this->getAbsolutePath($path);
1978
		$absolutePath = Filesystem::normalizePath($absolutePath);
1979
		if (!$this->shouldLockFile($absolutePath)) {
1980
			return false;
1981
		}
1982
1983
		$mount = $this->getMountForLock($absolutePath, $lockMountPoint);
1984
		if ($mount) {
1985
			try {
1986
				$storage = $mount->getStorage();
1987
				if ($storage->instanceOfStorage('\OCP\Files\Storage\ILockingStorage')) {
1988
					$storage->changeLock(
1989
						$mount->getInternalPath($absolutePath),
1990
						$type,
1991
						$this->lockingProvider
1992
					);
1993
				}
1994
			} catch (LockedException $e) {
1995
				// rethrow with the a human-readable path
1996
				throw new LockedException(
1997
					$this->getPathRelativeToFiles($absolutePath),
1998
					$e
1999
				);
2000
			}
2001
		}
2002
2003
		return true;
2004
	}
2005
2006
	/**
2007
	 * Unlock the given path