Lumaktaw patungo sa pangunahing content

FileLockManagerInMemory

This is the file lock manager for use within JS runtimes like Node.js.

A FileLockManagerInMemory is a wrapper around a Map of FileLock instances. It provides methods for locking and unlocking files, as well as finding conflicting locks.

Implements

Index

Constructors

constructor

Properties

locks

locks: Map<string, FileLock>

Methods

findFirstConflictingByteRangeLock

  • Find the first conflicting byte range lock.


    Parameters

    • path: string

      The path to the file to find the conflicting lock for.

    • desiredLock: Omit<RequestedRangeLock, fd>

      The desired byte range lock.

    Returns Omit<RequestedRangeLock, 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: Omit<RequestedRangeLock, fd>

      The byte range lock to perform.

    Returns boolean

    True if the lock was granted, false otherwise.

lockWholeFile

  • lockWholeFile(path: string, op: Omit<WholeFileLockOp, waitForLock>): boolean
  • 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: Omit<WholeFileLockOp, waitForLock>

      The whole file lock operation to perform.

    Returns boolean

    True if the lock was granted, false otherwise.

releaseLocksForProcess

  • releaseLocksForProcess(pid: number): void
  • Release all locks for the given process.


    Parameters

    • pid: number

      The process ID to release locks for.

    Returns void

releaseLocksOnFdClose

  • releaseLocksOnFdClose(pid: number, fd: number, nativePath: string): void
  • 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