WriteStream
Extends:
A stream that writes Nodes to the file system.
Test:
Constructor Summary
Public Constructor | ||
public |
constructor(options: Object) Creates a new WriteStream. |
Member Summary
Public Members | ||
public get |
If the stream is destroyed. |
Private Members | ||
private |
The base to output to. |
|
private |
|
|
private |
The IDs that are affected by node id conflicts, lowercased. |
|
private |
The number of id conflicts discovered. |
|
private |
_idMap: * A map of ids used for renaming. |
|
private |
If the stream is destroyed. |
|
private |
A promise that resolves once the rename file is loaded. |
|
private |
If writes should actually be performed. |
|
private |
The number of processed nodes. |
|
private |
_renameConfig: {} The object stored in the rename file (usually at './atscm/rename.json') |
|
private |
_renamesUsed: {} |
|
private |
The number of written nodes. |
Method Summary
Public Methods | ||
public |
writeAsync(node: *): * |
|
public |
writeRenamefile(): * Writes the updated rename config to disk. |
Private Methods | ||
private |
Destroys the stream. |
|
private |
async _outputFile(path: *, content: *): * |
|
private |
_parentHasIdConflict(node: ServerNode): boolean Transverses the node tree to see if any parent node has an id conflict. |
|
private |
Writes a single node to the file system. |
|
private |
async _writeNode(node: ServerNode): Promise<boolean> Writes a single node to disk. |
|
private |
Writes multiple nodes in parallel. |
Public Constructors
public constructor(options: Object) source
Creates a new WriteStream.
Params:
Name | Type | Attribute | Description |
options | Object | The options to use. |
|
options.path | string | The path to write to (required). |
|
options.base | string | The base path to write to (defaults to path). |
|
options.cleanRenameConfig | boolean |
|
If unused entries should be removed when rename config is written. |
Public Members
Private Members
private _cleanRenameConfig: * source
private _conflictingIds: Set<string> source
The IDs that are affected by node id conflicts, lowercased.
private _performWrites: boolean source
If writes should actually be performed. Set to false
once id conflicts were discovered.
private _renameConfig: {} source
The object stored in the rename file (usually at './atscm/rename.json')
private _renamesUsed: {} source
Public Methods
Private Methods
private async _outputFile(path: *, content: *): * source
Params:
Name | Type | Attribute | Description |
path | * | ||
content | * |
Return:
* |
private _parentHasIdConflict(node: ServerNode): boolean source
Transverses the node tree to see if any parent node has an id conflict.
Params:
Name | Type | Attribute | Description |
node | ServerNode | The processed node. |
private _write(node: Node, enc: string, callback: function(err: ?Error): void) source
Writes a single node to the file system.
private async _writeNode(node: ServerNode): Promise<boolean> source
Writes a single node to disk.
Params:
Name | Type | Attribute | Description |
node | ServerNode | The processed node. |