diff --git a/lib/private/files/storage/storage.php b/lib/private/files/storage/storage.php index 8b34908e61..642544bad3 100644 --- a/lib/private/files/storage/storage.php +++ b/lib/private/files/storage/storage.php @@ -78,7 +78,7 @@ interface Storage extends \OCP\Files\Storage { public function getMetaData($path); /** - * @param string $path + * @param string $path The path of the file to acquire the lock for * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE * @param \OCP\Lock\ILockingProvider $provider * @throws \OCP\Lock\LockedException @@ -86,7 +86,7 @@ interface Storage extends \OCP\Files\Storage { public function acquireLock($path, $type, ILockingProvider $provider); /** - * @param string $path + * @param string $path The path of the file to release the lock for * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE * @param \OCP\Lock\ILockingProvider $provider */ diff --git a/lib/private/files/view.php b/lib/private/files/view.php index b499bbb364..b8bbd60f02 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -971,9 +971,9 @@ class View { } } catch (\Exception $e) { if (in_array('write', $hooks) || in_array('delete', $hooks)) { - $this->lockFile($path, ILockingProvider::LOCK_EXCLUSIVE); + $this->unlockFile($path, ILockingProvider::LOCK_EXCLUSIVE); } else { - $this->lockFile($path, ILockingProvider::LOCK_SHARED); + $this->unlockFile($path, ILockingProvider::LOCK_SHARED); } throw $e; } @@ -1638,6 +1638,10 @@ class View { return $result; } + /** + * @param string $path the path of the file to lock, relative to the view + * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE + */ private function lockPath($path, $type) { $mount = $this->getMount($path); if ($mount) { @@ -1651,6 +1655,10 @@ class View { } } + /** + * @param string $path the path of the file to unlock, relative to the view + * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE + */ private function unlockPath($path, $type) { $mount = $this->getMount($path); if ($mount) { @@ -1665,13 +1673,13 @@ class View { } /** - * Lock a path and all it's parents + * Lock a path and all its parents up to the root of the view * - * @param string $path - * @param int $type + * @param string $path the path of the file to lock relative to the view + * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE */ public function lockFile($path, $type) { - $path = rtrim($path, '/'); + $path = '/' . trim($path, '/'); $this->lockPath($path, $type); $parents = $this->getParents($path); @@ -1681,10 +1689,10 @@ class View { } /** - * Unlock a path and all it's parents + * Unlock a path and all its parents up to the root of the view * - * @param string $path - * @param int $type + * @param string $path the path of the file to lock relative to the view + * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE */ public function unlockFile($path, $type) { $path = rtrim($path, '/'); diff --git a/lib/public/files/storage.php b/lib/public/files/storage.php index ea1da57595..68d00fab34 100644 --- a/lib/public/files/storage.php +++ b/lib/public/files/storage.php @@ -416,7 +416,7 @@ interface Storage { public function moveFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath); /** - * @param string $path + * @param string $path The path of the file to acquire the lock for * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE * @param \OCP\Lock\ILockingProvider $provider * @throws \OCP\Lock\LockedException @@ -424,7 +424,7 @@ interface Storage { public function acquireLock($path, $type, ILockingProvider $provider); /** - * @param string $path + * @param string $path The path of the file to acquire the lock for * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE * @param \OCP\Lock\ILockingProvider $provider */