FileLockManagerForNode
Implements
Index
Constructors
constructor
Returns FileLockManagerForNode
Properties
locks
Methods
findFirstConflictingByteRangeLock
Find the first conflicting byte range lock.
Parameters
path: string
The path to the file to find the conflicting lock for.
desiredLock: Readonly<{ end: bigint; pid: number; start: bigint; type: shared | exclusive | unlocked }>
The desired byte range lock.
Returns Omit<Readonly<{ end: bigint; pid: number; start: bigint; type: shared | exclusive | unlocked }>, fd>
The first conflicting byte range lock, or undefined if no conflicting lock exists.
lockFileByteRange
Lock a byte range.
Parameters
path: string
The path to the file to lock. This should be the path of the file in the native filesystem.
requestedLock: Readonly<{ end: bigint; pid: number; start: bigint; type: shared | exclusive | unlocked }>
The byte range lock to perform.
Returns boolean
True if the lock was granted, false otherwise.
lockWholeFile
Lock the whole file.
Parameters
path: string
The path to the file to lock. This should be the path of the file in the native filesystem.
op: WholeFileLockOp
The whole file lock operation to perform.
Returns boolean
True if the lock was granted, false otherwise.
releaseLocksForProcess
Release all locks for the given process.
Parameters
pid: number
The process ID to release locks for.
Returns void
releaseLocksForProcessFd
Release all locks for the given process and file descriptor.
Parameters
pid: number
The process ID to release locks for.
fd: number
The file descriptor to release locks for.
nativePath: string
Returns void
This is the file lock manager for use within JS runtimes like Node.js.
A FileLockManagerForNode is a wrapper around a Map of FileLock instances. It provides methods for locking and unlocking files, as well as finding conflicting locks.