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