aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/files/node.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/public/files/node.php')
-rw-r--r--lib/public/files/node.php51
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/public/files/node.php b/lib/public/files/node.php
index ee3f0cb0413..c69077c7f2a 100644
--- a/lib/public/files/node.php
+++ b/lib/public/files/node.php
@@ -225,4 +225,55 @@ interface Node extends FileInfo {
* @since 6.0.0
*/
public function getName();
+
+ /**
+ * Acquire a lock on this file or folder.
+ *
+ * A shared (read) lock will prevent any exclusive (write) locks from being created but any number of shared locks
+ * can be active at the same time.
+ * An exclusive lock will prevent any other lock from being created (both shared and exclusive).
+ *
+ * A locked exception will be thrown if any conflicting lock already exists
+ *
+ * Note that this uses mandatory locking, if you acquire an exclusive lock on a file it will block *all*
+ * other operations for that file, even within the same php process.
+ *
+ * Acquiring any lock on a file will also create a shared lock on all parent folders of that file.
+ *
+ * Note that in most cases you won't need to manually manage the locks for any files you're working with,
+ * any filesystem operation will automatically acquire the relevant locks for that operation.
+ *
+ * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
+ * @throws \OCP\Lock\LockedException
+ * @since 9.1.0
+ */
+ public function lock($type);
+
+ /**
+ * Check the type of an existing lock.
+ *
+ * A shared lock can be changed to an exclusive lock is there is exactly one shared lock on the file,
+ * an exclusive lock can always be changed to a shared lock since there can only be one exclusive lock int he first place.
+ *
+ * A locked exception will be thrown when these preconditions are not met.
+ * Note that this is also the case if no existing lock exists for the file.
+ *
+ * @param int $targetType \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
+ * @throws \OCP\Lock\LockedException
+ * @since 9.1.0
+ */
+ public function changeLock($targetType);
+
+ /**
+ * Release an existing lock.
+ *
+ * This will also free up the shared locks on any parent folder that were automatically acquired when locking the file.
+ *
+ * Note that this method will not give any sort of error when trying to free a lock that doesn't exist.
+ *
+ * @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
+ * @throws \OCP\Lock\LockedException
+ * @since 9.1.0
+ */
+ public function unlock($type);
}