Options
All
  • Public
  • Public/Protected
  • All
Menu

Module Daemon/TempVolume

Index

Functions

createTempDir

  • createTempDir(): Promise<string>
  • Create a temporary directory. Instead of this, use withTempDir whenever possible.

    Returns Promise<string>

    Asynchronously, the absolute path to a temporary directory.

destroyTempDir

  • destroyTempDir(path: string): Promise<void>
  • Clean up a temporary directory created with createTempDir. Instead of this, use withTempDir whenever possible.

    Parameters

    • path: string

      The path to the temporary directory.

    Returns Promise<void>

    Asynchronously, if and when the cleanup is successful.

safeResolve

  • safeResolve(root: string, file: string): string | undefined
  • Resolve a relative filename within a root directory. This is a security-critical function. It prevents pathname traversal.

    see

    https://nodejs.org/en/knowledge/file-system/security/introduction/

    Parameters

    • root: string

      Absolute path to the directory that must not be exited.

    • file: string

      Something that should be a relative path.

    Returns string | undefined

    The absolute path to the named file.

withTempDir

  • withTempDir<R>(action: (root: string) => Promise<R>): Promise<R>
  • Provide a temporary directory for as long as the given promise executes. It safely cleans up the directory once the promise settles.

    Type parameters

    • R

    Parameters

    • action: (root: string) => Promise<R>

      A function that will get the absolute path to a temporary directory.

        • (root: string): Promise<R>
        • Parameters

          • root: string

          Returns Promise<R>

    Returns Promise<R>

    The same as the given promise.

Generated using TypeDoc