Options
All
  • Public
  • Public/Protected
  • All
Menu

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. A namespace for ContentsManager statics.

This includes checkpointing with the normal file operations.

Hierarchy

  • ContentsManager

Implements

Index

Constructors

constructor

Properties

Private _additionalDrives

_additionalDrives: Map<string, IDrive> = new Map<string, Contents.IDrive>()

Private _defaultDrive

_defaultDrive: IDrive

Private _fileChanged

_fileChanged: Signal<this, IChangedArgs> = new Signal<this, Contents.IChangedArgs>(this)

Private _isDisposed

_isDisposed: boolean = false

serverSettings

serverSettings: ISettings

The server settings associated with the manager.

Accessors

fileChanged

isDisposed

  • get isDisposed(): boolean

Methods

Private _driveForPath

  • _driveForPath(path: string): [IDrive, string]
  • Given a path, get the IDrive to which it refers, where the path satisfies the pattern'driveName:path/to/file'. If there is nodriveName` prepended to the path, it returns the default drive.

    Parameters

    • path: string

    Returns [IDrive, string]

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

Private _onFileChanged

  • 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.

    Parameters

    Returns void

Private _toGlobalPath

  • _toGlobalPath(drive: IDrive, localPath: string): string
  • Given a drive and a local path, construct a fully qualified path. The inverse of _driveForPath.

    Parameters

    • drive: IDrive
    • localPath: string

    Returns string

    the fully qualified path.

addDrive

  • addDrive(drive: IDrive): void

copy

  • copy(fromFile: string, toDir: string): Promise<IModel>
  • Copy a file into a given directory.

    Parameters

    • fromFile: string
    • toDir: string

      The destination directory path.

    Returns Promise<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.

createCheckpoint

delete

  • delete(path: string): Promise<void>
  • Delete a file.

    Parameters

    • path: string

      The path to the file.

    Returns Promise<void>

    A promise which resolves when the file is deleted.

deleteCheckpoint

  • deleteCheckpoint(path: string, checkpointID: string): Promise<void>
  • 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

  • dispose(): void

driveName

  • driveName(path: string): string
  • 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

getDownloadUrl

  • getDownloadUrl(path: string): Promise<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.

    Returns Promise<string>

getModelDBFactory

  • getModelDBFactory(path: string): IFactory | null
  • Given a path, get a ModelDB.IFactory from the relevant backend. Returns null if the backend does not provide one.

    Parameters

    • path: string

    Returns IFactory | null

listCheckpoints

localPath

  • localPath(path: string): string
  • 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.

newUntitled

  • Create a new untitled file or directory in the specified directory path.

    Parameters

    Returns Promise<IModel>

    A promise which resolves with the created file content when the file is created.

normalize

  • normalize(path: string): string
  • 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

  • rename(path: string, newPath: string): Promise<IModel>
  • Rename a file or directory.

    Parameters

    • path: string

      The original file path.

    • newPath: string

      The new file path.

    Returns Promise<IModel>

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

restoreCheckpoint

  • restoreCheckpoint(path: string, checkpointID: string): Promise<void>
  • 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

  • save(path: string, options?: Partial<IModel>): Promise<IModel>
  • Save a file.

    Parameters

    • path: string

      The desired file path.

    • Default value options: Partial<IModel> = {}

      Optional overrides to the model.

    Returns Promise<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