Code Duplication    Length = 26-27 lines in 2 locations

lib/private/files/view.php 2 locations

@@ 1790-1815 (lines=26) @@
1787
	 * @return bool False if the path is excluded from locking, true otherwise
1788
	 * @throws \OCP\Lock\LockedException if the path is already locked
1789
	 */
1790
	private function lockPath($path, $type, $lockMountPoint = false) {
1791
		$absolutePath = $this->getAbsolutePath($path);
1792
		$absolutePath = Filesystem::normalizePath($absolutePath);
1793
		if (!$this->shouldLockFile($absolutePath)) {
1794
			return false;
1795
		}
1796
1797
		$mount = $this->getMountForLock($absolutePath, $lockMountPoint);
1798
		if ($mount) {
1799
			try {
1800
				$mount->getStorage()->acquireLock(
1801
					$mount->getInternalPath($absolutePath),
1802
					$type,
1803
					$this->lockingProvider
1804
				);
1805
			} catch (\OCP\Lock\LockedException $e) {
1806
				// rethrow with the a human-readable path
1807
				throw new \OCP\Lock\LockedException(
1808
					$this->getPathRelativeToFiles($absolutePath),
1809
					$e
1810
				);
1811
			}
1812
		}
1813
1814
		return true;
1815
	}
1816
1817
	/**
1818
	 * Change the lock type
@@ 1827-1853 (lines=27) @@
1824
	 * @return bool False if the path is excluded from locking, true otherwise
1825
	 * @throws \OCP\Lock\LockedException if the path is already locked
1826
	 */
1827
	public function changeLock($path, $type, $lockMountPoint = false) {
1828
		$path = Filesystem::normalizePath($path);
1829
		$absolutePath = $this->getAbsolutePath($path);
1830
		$absolutePath = Filesystem::normalizePath($absolutePath);
1831
		if (!$this->shouldLockFile($absolutePath)) {
1832
			return false;
1833
		}
1834
1835
		$mount = $this->getMountForLock($absolutePath, $lockMountPoint);
1836
		if ($mount) {
1837
			try {
1838
				$mount->getStorage()->changeLock(
1839
					$mount->getInternalPath($absolutePath),
1840
					$type,
1841
					$this->lockingProvider
1842
				);
1843
			} catch (\OCP\Lock\LockedException $e) {
1844
				// rethrow with the a human-readable path
1845
				throw new \OCP\Lock\LockedException(
1846
					$this->getPathRelativeToFiles($absolutePath),
1847
					$e
1848
				);
1849
			}
1850
		}
1851
1852
		return true;
1853
	}
1854
1855
	/**
1856
	 * Unlock the given path