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.

This includes checkpointing with the normal file operations.

Hierarchy

  • ContentsManager

Implements

Index

Constructors

constructor

  • Construct a new contents manager object.

    Parameters

    • Optional options: IOptions

      The options used to initialize the object.

    Returns ContentsManager

Properties

Private _additionalDrives

_additionalDrives: any

Private _defaultDrive

_defaultDrive: any

Private _driveForPath

_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

a path to a file.

returns

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

Private _fileChanged

_fileChanged: any

Private _isDisposed

_isDisposed: any

Private _onFileChanged

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

Private _toGlobalPath

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

Readonly serverSettings

serverSettings: ISettings

The server settings associated with the manager.

Accessors

fileChanged

  • A signal emitted when a file operation takes place.

    Returns ISignal<this, IChangedArgs>

isDisposed

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

    Returns boolean

Methods

addDrive

  • addDrive(drive: IDrive): void
  • Add an IDrive to the manager.

    Parameters

    Returns 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

  • Create a checkpoint for a file.

    Parameters

    • path: string

      The path of the file.

    Returns Promise<ICheckpointModel>

    A promise which resolves with the new checkpoint model when the checkpoint is created.

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
  • Dispose of the resources held by the manager.

    Returns 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

  • Get a file or directory.

    Parameters

    Returns Promise<IModel>

    A promise which resolves with the file content.

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.

      The returned URL may include a query parameter.

    Returns Promise<string>

getModelDBFactory

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

    Parameters

    • path: string

    Returns IFactory | null

listCheckpoints

  • List available checkpoints for a file.

    Parameters

    • path: string

      The path of the file.

    Returns Promise<ICheckpointModel[]>

    A promise which resolves with a list of checkpoint models for the file.

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.

resolvePath

  • resolvePath(root: string, path: string): string
  • 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.

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.

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