|
@@ 1993-2008 (lines=16) @@
|
| 1990 |
|
* |
| 1991 |
|
* @return bool False if the path is excluded from locking, true otherwise |
| 1992 |
|
*/ |
| 1993 |
|
public function lockFile($path, $type, $lockMountPoint = false) { |
| 1994 |
|
$absolutePath = $this->getAbsolutePath($path); |
| 1995 |
|
$absolutePath = Filesystem::normalizePath($absolutePath); |
| 1996 |
|
if (!$this->shouldLockFile($absolutePath)) { |
| 1997 |
|
return false; |
| 1998 |
|
} |
| 1999 |
|
|
| 2000 |
|
$this->lockPath($path, $type, $lockMountPoint); |
| 2001 |
|
|
| 2002 |
|
$parents = $this->getParents($path); |
| 2003 |
|
foreach ($parents as $parent) { |
| 2004 |
|
$this->lockPath($parent, ILockingProvider::LOCK_SHARED); |
| 2005 |
|
} |
| 2006 |
|
|
| 2007 |
|
return true; |
| 2008 |
|
} |
| 2009 |
|
|
| 2010 |
|
/** |
| 2011 |
|
* Unlock a path and all its parents up to the root of the view |
|
@@ 2019-2034 (lines=16) @@
|
| 2016 |
|
* |
| 2017 |
|
* @return bool False if the path is excluded from locking, true otherwise |
| 2018 |
|
*/ |
| 2019 |
|
public function unlockFile($path, $type, $lockMountPoint = false) { |
| 2020 |
|
$absolutePath = $this->getAbsolutePath($path); |
| 2021 |
|
$absolutePath = Filesystem::normalizePath($absolutePath); |
| 2022 |
|
if (!$this->shouldLockFile($absolutePath)) { |
| 2023 |
|
return false; |
| 2024 |
|
} |
| 2025 |
|
|
| 2026 |
|
$this->unlockPath($path, $type, $lockMountPoint); |
| 2027 |
|
|
| 2028 |
|
$parents = $this->getParents($path); |
| 2029 |
|
foreach ($parents as $parent) { |
| 2030 |
|
$this->unlockPath($parent, ILockingProvider::LOCK_SHARED); |
| 2031 |
|
} |
| 2032 |
|
|
| 2033 |
|
return true; |
| 2034 |
|
} |
| 2035 |
|
|
| 2036 |
|
/** |
| 2037 |
|
* Only lock files in data/user/files/ |