ILockingStorage.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCP\Files\Storage;
  8. use OCP\Lock\ILockingProvider;
  9. /**
  10. * Storage backends that require explicit locking
  11. *
  12. * Storage backends implementing this interface do not need to implement their own locking implementation but should use the provided lockingprovider instead
  13. * The implementation of the locking methods only need to map internal storage paths to "lock keys"
  14. *
  15. * @since 9.0.0
  16. */
  17. interface ILockingStorage {
  18. /**
  19. * @param string $path The path of the file to acquire the lock for
  20. * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
  21. * @throws \OCP\Lock\LockedException
  22. * @since 9.0.0
  23. */
  24. public function acquireLock(string $path, int $type, ILockingProvider $provider);
  25. /**
  26. * @param string $path The path of the file to acquire the lock for
  27. * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
  28. * @throws \OCP\Lock\LockedException
  29. * @since 9.0.0
  30. */
  31. public function releaseLock(string $path, int $type, ILockingProvider $provider);
  32. /**
  33. * @param string $path The path of the file to change the lock for
  34. * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
  35. * @throws \OCP\Lock\LockedException
  36. * @since 9.0.0
  37. */
  38. public function changeLock(string $path, int $type, ILockingProvider $provider);
  39. }