Class ContentsManager

A contents manager that passes file operations to the server. Multiple servers implementing the IDrive interface can be attached to the contents manager, so that the same session can perform file operations on multiple backends.

This includes checkpointing with the normal file operations.

Hierarchy

  • ContentsManager

Implements

Constructors

  • Construct a new contents manager object.

    Parameters

    Returns ContentsManager

Properties

_additionalDrives: any
_defaultDrive: any
_driveForPath: any

Given a path, get the IDrive to which it refers, where the path satisfies the pattern 'driveName:path/to/file'. If there is no driveName` prepended to the path, it returns the default drive.

@param path: a path to a file.

@returns A tuple containing an IDrive object for the path, and a local path for that drive.

_fileChanged: any
_isDisposed: any
_onFileChanged: any

Respond to fileChanged signals from the drives attached to the manager. This prepends the drive name to the path if necessary, and then forwards the signal.

_toGlobalPath: any

Given a drive and a local path, construct a fully qualified path. The inverse of _driveForPath.

Param

an IDrive.

Param

the local path on the drive.

Returns

the fully qualified path.

serverSettings: ServerConnection.ISettings

The server settings associated with the manager.

Accessors

  • get isDisposed(): boolean
  • Test whether the manager has been disposed.

    Returns boolean

Methods

  • Add an IDrive to the manager.

    Parameters

    Returns void

  • Copy a file into a given directory.

    Parameters

    • fromFile: string
    • toDir: string

      The destination directory path.

    Returns Promise<Contents.IModel>

    A promise which resolves with the new contents model when the file is copied.

    Notes

    The server will select the name of the copied file.

  • Delete a file.

    Parameters

    • path: string

      The path to the file.

    Returns Promise<void>

    A promise which resolves when the file is deleted.

  • Delete a checkpoint for a file.

    Parameters

    • path: string

      The path of the file.

    • checkpointID: string

      The id of the checkpoint to delete.

    Returns Promise<void>

    A promise which resolves when the checkpoint is deleted.

  • Dispose of the resources held by the manager.

    Returns void

  • Given a path of the form drive:local/portion/of/it.txt get the name of the drive. If the path is missing a drive portion, returns an empty string.

    Parameters

    • path: string

    Returns string

    The drive name for the path, or the empty string.

  • Get an encoded download url given a file path.

    Parameters

    • path: string

      An absolute POSIX file path on the server.

      Notes

      It is expected that the path contains no relative paths.

      The returned URL may include a query parameter.

    Returns Promise<string>

  • Given a path, get a shared model factory from the relevant backend. Returns null if the backend does not provide one.

    Parameters

    • path: string

    Returns ISharedFactory

  • Given a path of the form drive:local/portion/of/it.txt get the local part of it.

    Parameters

    • path: string

    Returns string

    The local part of the path.

  • Normalize a global path. Reduces '..' and '.' parts, and removes leading slashes from the local part of the path, while retaining the drive name if it exists.

    Parameters

    • path: string

    Returns string

    The normalized path.

  • Rename a file or directory.

    Parameters

    • path: string

      The original file path.

    • newPath: string

      The new file path.

    Returns Promise<Contents.IModel>

    A promise which resolves with the new file contents model when the file is renamed.

  • Resolve a global path, starting from the root path. Behaves like posix-path.resolve, with 3 differences:

    • will never prepend cwd
    • if root has a drive name, the result is prefixed with ":"
    • before adding drive name, leading slashes are removed

    Parameters

    • root: string
    • path: string

    Returns string

    The normalized path.

  • Restore a file to a known checkpoint state.

    Parameters

    • path: string

      The path of the file.

    • checkpointID: string

      The id of the checkpoint to restore.

    Returns Promise<void>

    A promise which resolves when the checkpoint is restored.

  • Save a file.

    Parameters

    • path: string

      The desired file path.

    • Optional options: Partial<Contents.IModel>

      Optional overrides to the model.

    Returns Promise<Contents.IModel>

    A promise which resolves with the file content model when the file is saved.

    Notes

    Ensure that model.content is populated for the file.

Generated using TypeDoc