diff options
author | Robin Appelman <icewind@owncloud.com> | 2016-01-04 14:07:03 +0100 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2016-01-14 12:54:42 +0100 |
commit | 0724ac1e5ed83926ed9cbbb8c660b40ef1254da8 (patch) | |
tree | e68a90e2fb692ad1e2cb2f1c10163152bbbb288e | |
parent | 3deb3bd16399cd7e23a02b45c66e32495dbfda0d (diff) | |
download | nextcloud-server-0724ac1e5ed83926ed9cbbb8c660b40ef1254da8.tar.gz nextcloud-server-0724ac1e5ed83926ed9cbbb8c660b40ef1254da8.zip |
split locking related methods to their own interface
-rw-r--r-- | lib/private/files/storage/common.php | 3 | ||||
-rw-r--r-- | lib/public/files/storage/ilockingstorage.php | 60 | ||||
-rw-r--r-- | lib/public/files/storage/istorage.php | 27 |
3 files changed, 62 insertions, 28 deletions
diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php index c27f9d759f1..95bb3f74ba7 100644 --- a/lib/private/files/storage/common.php +++ b/lib/private/files/storage/common.php @@ -46,6 +46,7 @@ use OCP\Files\FileNameTooLongException; use OCP\Files\InvalidCharacterInPathException; use OCP\Files\InvalidPathException; use OCP\Files\ReservedWordException; +use OCP\Files\Storage\ILockingStorage; use OCP\Lock\ILockingProvider; /** @@ -59,7 +60,7 @@ use OCP\Lock\ILockingProvider; * Some \OC\Files\Storage\Common methods call functions which are first defined * in classes which extend it, e.g. $this->stat() . */ -abstract class Common implements Storage { +abstract class Common implements Storage, ILockingStorage { use LocalTempFileTrait; diff --git a/lib/public/files/storage/ilockingstorage.php b/lib/public/files/storage/ilockingstorage.php new file mode 100644 index 00000000000..32cc32ffb05 --- /dev/null +++ b/lib/public/files/storage/ilockingstorage.php @@ -0,0 +1,60 @@ +<?php +/** + * @author Robin Appelman <icewind@owncloud.com> + * + * @copyright Copyright (c) 2015, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ + +namespace OCP\Files\Storage; + +use OCP\Lock\ILockingProvider; + +/** + * Storage backends that require explicit locking + * + * Storage backends implementing this interface do not need to implement their own locking implementation but should use the provided lockingprovider instead + * The implementation of the locking methods only need to map internal storage paths to "lock keys" + * + * @since 9.0.0 + */ +interface ILockingStorage { + /** + * @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 + * @since 9.0.0 + */ + public function acquireLock($path, $type, ILockingProvider $provider); + + /** + * @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 + * @since 9.0.0 + */ + public function releaseLock($path, $type, ILockingProvider $provider); + + /** + * @param string $path The path of the file to change 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 + * @since 9.0.0 + */ + public function changeLock($path, $type, ILockingProvider $provider); +} diff --git a/lib/public/files/storage/istorage.php b/lib/public/files/storage/istorage.php index 377bb96ea2b..4bc5e3536dc 100644 --- a/lib/public/files/storage/istorage.php +++ b/lib/public/files/storage/istorage.php @@ -40,7 +40,6 @@ use OCP\Files\Cache\IScanner; use OCP\Files\Cache\IUpdater; use OCP\Files\Cache\IWatcher; use OCP\Files\InvalidPathException; -use OCP\Lock\ILockingProvider; /** * Provide a common interface to all different storage options @@ -426,32 +425,6 @@ interface IStorage { public function moveFromStorage(\OCP\Files\Storage $sourceStorage, $sourceInternalPath, $targetInternalPath); /** - * @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 - * @since 9.0.0 - */ - public function acquireLock($path, $type, ILockingProvider $provider); - - /** - * @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 - * @since 9.0.0 - */ - public function releaseLock($path, $type, ILockingProvider $provider); - - /** - * @param string $path The path of the file to change 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 - * @since 9.0.0 - */ - public function changeLock($path, $type, ILockingProvider $provider); - - /** * Test a storage for availability * * @since 9.0.0 |