Class LockManagerBase
The base implementation for an ILockManager
Inherited Members
Namespace:FubarDev.WebDavServer.Locking
Assembly:FubarDev.WebDavServer.dll
Syntax
public abstract class LockManagerBase : ILockManager
Remarks
The derived class must implement BeginTransactionAsync(CancellationToken) and return an object that implements LockManagerBase.ILockManagerTransaction.
Constructors
| Improve this Doc View SourceLockManagerBase(ILockCleanupTask, ISystemClock, ILogger, ILockManagerOptions)
Initializes a new instance of the LockManagerBase class.
Declaration
protected LockManagerBase([NotNull] ILockCleanupTask cleanupTask, [NotNull] ISystemClock systemClock, [NotNull] ILogger logger, [CanBeNull] ILockManagerOptions options = null)
Parameters
Type | Name | Description |
---|---|---|
ILockCleanupTask | cleanupTask | The clean-up task for expired locks |
ISystemClock | systemClock | The system clock interface |
Microsoft.Extensions.Logging.ILogger | logger | The logger |
ILockManagerOptions | options | The options of the lock manager |
Properties
| Improve this Doc View SourceCost
Gets the cost of a LOCK/UNLOCK or lock discovery operation
Declaration
public int Cost { get; }
Property Value
Type | Description |
---|---|
Int32 |
Implements
| Improve this Doc View SourceLockCleanupTask
Gets the lock cleanup task
Declaration
[NotNull]
protected ILockCleanupTask LockCleanupTask { get; }
Property Value
Type | Description |
---|---|
ILockCleanupTask |
Methods
| Improve this Doc View SourceBeginTransactionAsync(CancellationToken)
Begins a new transaction
Declaration
protected abstract Task<LockManagerBase.ILockManagerTransaction> BeginTransactionAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | The cancellation token |
Returns
Type | Description |
---|---|
Task<LockManagerBase.ILockManagerTransaction> | The transaction to be used to update the active locks |
GetAffectedLocksAsync(String, Boolean, Boolean, CancellationToken)
Gets all active locks
Declaration
public Task<IEnumerable<IActiveLock>> GetAffectedLocksAsync(string path, bool findChildren, bool findParents, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
String | path | The file system path to get the locks for |
Boolean | findChildren | Return all locks that are a child of the given path? |
Boolean | findParents | Return all locks that are a parent of the given path? |
CancellationToken | cancellationToken | The cancellation token |
Returns
Type | Description |
---|---|
Task<IEnumerable<IActiveLock>> | Returns all active locks |
Implements
Remarks
Be aware that the locks could've been released in the mean time by a concurrent access or by the LockCleanupTask.
GetLocksAsync(CancellationToken)
Gets all active locks
Declaration
public Task<IEnumerable<IActiveLock>> GetLocksAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | The cancellation token |
Returns
Type | Description |
---|---|
Task<IEnumerable<IActiveLock>> | Returns all active locks |
Implements
Remarks
Be aware that the locks could've been released in the mean time by a concurrent access or by the LockCleanupTask.
LockAsync(ILock, CancellationToken)
Tries to issue a lock
Declaration
public Task<LockResult> LockAsync(ILock l, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
ILock | l | The lock to issue |
CancellationToken | cancellationToken | The cancellation token |
Returns
Type | Description |
---|---|
Task<LockResult> | Either the list of locks preventing issuing a lock or the active lock created |
Implements
| Improve this Doc View SourceLockImplicitAsync(IFileSystem, IReadOnlyCollection<IfHeaderList>, ILock, CancellationToken)
Tries to find a lock identified by the ifHeaderLists or creates a new one if none was found.
Declaration
public Task<IImplicitLock> LockImplicitAsync(IFileSystem rootFileSystem, IReadOnlyCollection<IfHeaderList> ifHeaderLists, ILock lockRequirements, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
IFileSystem | rootFileSystem | The root file system to identify the lock for |
IReadOnlyCollection<IfHeaderList> | ifHeaderLists | The |
ILock | lockRequirements | The requirements the found lock must meet |
CancellationToken | cancellationToken | The cancellation token |
Returns
Type | Description |
---|---|
Task<IImplicitLock> | Either the list of locks preventing issuing a lock or the active lock created or reused |
Implements
| Improve this Doc View SourceNormalizePath(Uri)
Converts a client path to a system path.
Declaration
protected virtual Uri NormalizePath(Uri path)
Parameters
Type | Name | Description |
---|---|---|
Uri | path | The client path to convert |
Returns
Type | Description |
---|---|
Uri | The system path to be converted to |
Remarks
The client path has the form http://localhost/root-file-system/relative/path
and is
therefore always an absolute path. The returned path must be absolute too and might have
the form http://localhost/c/relative/path
or something similar. It is of utmost
importance that the URI is always stable. The default implementation of this function
doesn't make any conversions, because it assumes that the same path path always points
to the same file system entry for all clients.
A URI to a directory must always end in a slash (/
).
OnLockAdded(IActiveLock)
Gets called when a lock was added
Declaration
protected virtual void OnLockAdded(IActiveLock activeLock)
Parameters
Type | Name | Description |
---|---|---|
IActiveLock | activeLock | The lock that was added |
OnLockReleased(IActiveLock)
Gets called when a lock was released
Declaration
protected virtual void OnLockReleased(IActiveLock activeLock)
Parameters
Type | Name | Description |
---|---|---|
IActiveLock | activeLock | The lock that was released |
RefreshLockAsync(IFileSystem, IfHeader, TimeSpan, CancellationToken)
Tries to refresh a lock
Declaration
public Task<LockRefreshResult> RefreshLockAsync(IFileSystem rootFileSystem, IfHeader ifHeader, TimeSpan timeout, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
IFileSystem | rootFileSystem | The root file system |
IfHeader | ifHeader | The header that tries to identify the lock to refresh |
TimeSpan | timeout | The header containing the new timeouts |
CancellationToken | cancellationToken | The cancellation token |
Returns
Type | Description |
---|---|
Task<LockRefreshResult> | Either the list of locks preventing refreshing a lock or the refreshed lock |
Implements
| Improve this Doc View SourceReleaseAsync(String, Uri, CancellationToken)
Releases a lock with the given state token
Declaration
public Task<LockReleaseStatus> ReleaseAsync(string path, Uri stateToken, CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
String | path | The path to release the lock for |
Uri | stateToken | The state token of the lock to release |
CancellationToken | cancellationToken | The cancellation token |
Returns
Type | Description |
---|---|
Task<LockReleaseStatus> | true when there was a lock to remove |
Implements
Events
| Improve this Doc View SourceLockAdded
Gets called when a lock was added
Declaration
public event EventHandler<LockEventArgs> LockAdded
Event Type
Type | Description |
---|---|
EventHandler<LockEventArgs> |
Implements
| Improve this Doc View SourceLockReleased
Gets called when a lock was released
Declaration
public event EventHandler<LockEventArgs> LockReleased
Event Type
Type | Description |
---|---|
EventHandler<LockEventArgs> |