ILockingProvider.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  6. * SPDX-License-Identifier: AGPL-3.0-only
  7. */
  8. namespace OCP\Lock;
  9. /**
  10. * This interface allows locking and unlocking filesystem paths
  11. *
  12. * This interface should be used directly and not implemented by an application.
  13. * The implementation is provided by the server.
  14. *
  15. * @since 8.1.0
  16. */
  17. interface ILockingProvider {
  18. /**
  19. * @since 8.1.0
  20. */
  21. public const LOCK_SHARED = 1;
  22. /**
  23. * @since 8.1.0
  24. */
  25. public const LOCK_EXCLUSIVE = 2;
  26. /**
  27. * @psalm-param self::LOCK_SHARED|self::LOCK_EXCLUSIVE $type
  28. * @since 8.1.0
  29. */
  30. public function isLocked(string $path, int $type): bool;
  31. /**
  32. * @psalm-param self::LOCK_SHARED|self::LOCK_EXCLUSIVE $type
  33. * @param ?string $readablePath A human-readable path to use in error messages, since 20.0.0
  34. * @throws LockedException
  35. * @since 8.1.0
  36. */
  37. public function acquireLock(string $path, int $type, ?string $readablePath = null): void;
  38. /**
  39. * @psalm-param self::LOCK_SHARED|self::LOCK_EXCLUSIVE $type
  40. * @since 8.1.0
  41. */
  42. public function releaseLock(string $path, int $type): void;
  43. /**
  44. * Change the target type of an existing lock
  45. *
  46. * @psalm-param self::LOCK_SHARED|self::LOCK_EXCLUSIVE $targetType
  47. * @throws LockedException
  48. * @since 8.1.0
  49. */
  50. public function changeLock(string $path, int $targetType): void;
  51. /**
  52. * Release all lock acquired by this instance
  53. * @since 8.1.0
  54. */
  55. public function releaseAll(): void;
  56. }