Skip to main content

HashDownloadPipeline

HashDownloadPipeline is an abstract extension of DownloadPipeline designed to handle downloads using hash-based storage adapters (HashStorageAdapter). It orchestrates the process of scanning directories, computing deltas with DeltaService, downloading missing chunks, and reconstructing files.

This pipeline is commonly used when downloading from storage systems where chunks are identified by their hash.


Constructor

ParameterTypeDescription
storageHashStorageAdapterHash based storage adapter that will be used (automatically created by client).
deltaDeltaServiceDeltaService used for generate rd-index, comparing rd-index, etc.
reconstructionReconstructionServiceReconstructionService used for local file reconstruction.
validationValidationServiceValidationService used for file validation after reconstruction.
configRacDeltaConfigBase client configuration.

Methods

MethodReturnsDescription
execute(localDir, strategy, remoteIndex?, options?)Promise<void>Performs a full download process for a directory.
downloadAllMissingChunks(plan, target, options?)Promise<ChunkSource>This method will download first all needed chunks, and save them temporary on disk or memory.

Method details

execute(localDir, strategy, remoteIndex?, options?)

Performs a full download process for a directory.

Parameters

NameTypeDescription
localDirstringDirectory where the new update will be downloaded.
strategyUpdateStrategyStrategy used for downloading and reconstruction. See UpdateStrategy
remoteIndexRDIndexOptional remote rd-index. If none provided, will try to download from storage.
optionsDownloadOptionsOptions for the download process. See DownloadOptions

Returns

Promise<void>


downloadAllMissingChunks(plan, target, options?)

This method will download first all needed chunks for download, and save them temporary on disk or memory.

Will return ChunkSource, ChunkSources will be needed to reconstruct files, this method will ONLY return memory or disk chunk sources for offline reconstruction, if you use a storage like S3, you can omit this and use directly the StorageChunkSource with reconstruction.reconstructAll() if you prefer.

(Using StorageChunkSource will download chunks and reconstruct file at same time, concurrently)

Parameters

NameTypeDescription
planDeltaPlanThe DeltaPlan generated by delta.compare of the two rd-index.json for the download.
target'memory' | 'disk'Target of the resulting ChunkSource.
optionsDownloadOptionsOptions for the download process. See DownloadOptions

Returns

Promise<ChunkSource>