Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
fa436b5b
Commit
fa436b5b
authored
9 years ago
by
Thomas Müller
Browse files
Options
Downloads
Plain Diff
Merge pull request #22812 from owncloud/node-lock
Add locking to the node api
parents
e5b5eca5
02635c6f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/private/files/node/node.php
+24
-0
24 additions, 0 deletions
lib/private/files/node/node.php
lib/public/files/node.php
+51
-0
51 additions, 0 deletions
lib/public/files/node.php
with
75 additions
and
0 deletions
lib/private/files/node/node.php
+
24
−
0
View file @
fa436b5b
...
...
@@ -356,4 +356,28 @@ class Node implements \OCP\Files\Node {
public
function
getChecksum
()
{
return
;
}
/**
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
* @throws \OCP\Lock\LockedException
*/
public
function
lock
(
$type
)
{
$this
->
view
->
lockFile
(
$this
->
path
,
$type
);
}
/**
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
* @throws \OCP\Lock\LockedException
*/
public
function
changeLock
(
$type
)
{
$this
->
view
->
changeLock
(
$this
->
path
,
$type
);
}
/**
* @param int $type \OCP\Lock\ILockingProvider::LOCK_SHARED or \OCP\Lock\ILockingProvider::LOCK_EXCLUSIVE
* @throws \OCP\Lock\LockedException
*/
public
function
unlock
(
$type
)
{
$this
->
view
->
unlockFile
(
$this
->
path
,
$type
);
}
}
This diff is collapsed.
Click to expand it.
lib/public/files/node.php
+
51
−
0
View file @
fa436b5b
...
...
@@ -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
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment