Page tree
Skip to end of metadata
Go to start of metadata

ON THIS PAGE

The assetpool object represents a pool of files for synchronization. An asset pool is populated with the assetpoolfetcher object.

assetpool IDL
[
    GarbageCollected
] interface AssetPool {
    AssetPool(DOMString poolPath);
    Promise<void> protectAssets(DOMString name, AssetList assets);
    Promise<void> unprotectAssets(DOMString name);
    Promise<void> reserveStorage(long size);
    Promise<void> setMaximumPoolSize(long size);
    Promise<long> getPoolSize();
    Promise<ValidationResultList> validate(AssetList assets, ValidationOptions options)
    Promise<QueryResultAssetList> queryFiles(AssetList assets);
    Promise<bool> areAssetsReady(AssetList);
};

interface AssetList {
    attribute DOMString name;
    attribute DOMString link;
    attribute long size;
    attribute Hash hash;
    attribute DOMString changeHint;
    [optional] attribute Authentication auth;
    [optional] attribute HeaderList headers;
    attribute DOMString probe;
};

interface ValidateOptions {
    attribute DOMString deleteCorruptFiles;
};

interface Hash {
    attribute DOMString method;
    attribute DOMString hex;
}

interface Authentication {
    attribute DOMString user;
    attribute DOMString password;
};

interface HeaderList {
    attribute DOMString name;
    attribute DOMString value;
};

interface QueryResultAssetList : Asset {
    attribute DOMString name;
    attribute bool present;
};

interface ValidationResultList : Asset {
    attribute DOMString name;
    attribute bool ok;
    attribute DOMString reason;
};

Object Creation

To create an assetpool object, first load the brightsign/assetpool module using the Require() method. Then create an instance of the assetpool class with a string value specifying the pool path.

var AssetPoolClass = require("@brightsign/assetpool");
var assetPool = new AssetPoolClass("SD:/pool");

AssetPool

Use this interface to perform operations on the asset pool.

protectAssets()
Promise<void> protectAssets(DOMString name, AssetList assets)

Requests that a set of files in the asset pool be protected from deletion when the system software needs to prune files from the pool to make space. The passed name is used to reference the set of files if their protection needs to be removed later using the unprotectAssets() method.

unprotectAssets()
Promise<void> unprotectAssets(DOMString name)

Removes protection from a set of files that have been protected using the protectAssets() method.

reserveStorage()
Promise<void> reserveStorage(long size)

Reserves the specified amount of storage space (in megabytes). This method is persistent: The system software attempts to keep the specified amount of space free even as parallel processes fill up the storage.

setMaximumPoolSize()
Promise<void> setMaximumPoolSize(long size)

Specifies the maximum size of the asset pool (in megabytes). This method is more resource-intensive than reserveStorage(), but it is useful when creating multiple pools on a storage device.

getPoolSize()
Promise<long> getPoolSize()

Returns the current size of the asset pool (in megabytes).

validate()
Promise<ValidtionResultList> validate(AssetList assets, ValidationOptions options)

Compares the passed file hash values against the hash values of the files in the asset pool. This method returns a ValidationResultList interface containing validation results for each file. The second parameter is a ValidationOptions interface specifying validation options.

queryFiles()
Promise<QueryResultAssetList> queryFiles(AssetList assets)

Determines whether the specified files are present in the asset pool. This method returns a QueryResultAssetList interface containing query results.

areAssetsReady()
Promise<bool> areAssetsReady(AssetList)

Returns true if the specified files are ready in the asset pool.

AssetList 

This interface represents a set of files in the asset pool. Each entry in the list contains the following parameters:

  • [DOMString] name: The filename. For a file to be realized, it must have a valid filename (i.e. no slashes).
  • [DOMString] link: The download URL of the file
  • [long] size: The file length (in bytes)
  • [Hash] hash: A Hash interface specifying the hash algorithm and hash value of the file
  • [DOMString] changeHint: An arbitrary value that can be used by the client to specify that a file has changed even when the hash value and download URL remain the same.
  • [optional] [Authentication] auth: An Authentication interface specifying the credentials to use when downloading the asset. By default, credentials are inherited from the assetpoolfetcher instance used to download the asset.
  • [optional] [HeaderList] headers: A HeaderList interface specifying headers that are passed to the download URL. By default, headers are inherited from the assetpoolfetcher instance used to download the asset.
  • [DOMString] probe: The media probe data

ValidateOptions

This interface contains validation options for the validate() method.

  • [DOMString] deleteCorruptFiles: A flag specifying whether corrupt files should be deleted during validation

Hash

This interface contains hash information about the file.

  • [DOMString] method: The hash algorithm. Accepted values include "SHA1", "BESHA1", and "MD5".
  • [DOMString] hex: The hash value in hexidecimal format

Authentication

This interface contains authentication information for downloading files.

  • [DOMString] user: The user name for authentication
  • [DOMString] password: The password for authentication

HeaderList

This interface contains a list of headers to pass to a file download URL. Each entry in the list contains the following parameters:

  • [DOMString] name: The header name
  • [DOMString] value: The header value

QueryResultAssetList

This interface is returned by the queryFiles() method. Each entry in the list contains the following parameters:

  • [DOMString] name: The name of the queried file
  • [bool] present: A flag indicating whether the queried file exists in the asset pool

ValidationResultList

This interface is returned by the validate() method. Each entry in the list contains the following parameters:

  • [DOMString] name: The name of the checked file
  • [bool] ok: A flag indicating whether the file has passed validation
  • [DOMString] reason: An explanation for a failed validation

 

  • No labels