Skip to main content

HashUploadPipeline

HashUploadPipeline is an abstract extension of UploadPipeline designed to handle uploads using hash-based storage adapters (HashStorageAdapter). It orchestrates the process of scanning directories, computing deltas with DeltaService, uploading missing chunks, and cleaning up obsolete chunks.

This pipeline is commonly used when uploading to 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.
configRacDeltaConfigBase client configuration.

Methods

MethodReturnsDescription
execute(directory, remoteIndex?, options?)Promise<RDIndex>Performs a full upload process for a directory.
scanDirectory(dir, ignorePatterns?)Promise<RDIndex>Scans the directory recursively and creates an RDIndex.
uploadMissingChunks(plan, baseDir, force, options?)Promise<void>Uploads only the missing or updated chunks defined in a DeltaPlan.
uploadIndex(index)Promise<void>Uploads the RDIndex file to the storage adapter.
deleteObsoleteChunks(delta, options?)Promise<void>Deletes obsolete chunks from the storage as specified by the delta plan.

Method details

execute(directory, remoteIndex?, options?)

Performs a full upload process for a directory. Returns the resulting RDIndex after upload.

Parameters

NameTypeDescription
directorystringDirectory that will be compared and uploaded.
remoteIndexRDIndexOptional remote rd-index. If none provided, will try to download from storage.
optionsUploadOptionsOptions for the upload process. See UploadOptions

Returns

Promise<RDIndex>


scanDirectory(dir, ignorePatterns?)

Scans the directory recursively and creates an RDIndex, ignoring files matching the provided patterns.

Parameters

NameTypeDescription
dirstringDirectory that will be scanned.
ignorePatternsstring[]Optional ignore patterns, these patterns will be ignored when creating the RDIndex.

Returns

Promise<RDIndex>


uploadMissingChunks(plan, baseDir, force, options?)

Uploads only the missing or updated chunks defined in a DeltaPlan.

Parameters

NameTypeDescription
planDeltaPlanThe delta plan indicating which chunks are missing.
baseDirstringBase directory containing local files.
forcebooleanIf true, will force overwrite of chunks in storage.
optionsUploadOptionsOptions for the upload process. See UploadOptions

Returns

Promise<void>


uploadIndex(index)

Uploads the RDIndex file to the storage adapter.

Parameters

NameTypeDescription
indexRDIndexThe index object to upload.

Returns

Promise<void>


deleteObsoleteChunks(delta, options?)

Deletes obsolete chunks from the storage as specified by the delta plan.

Parameters

NameTypeDescription
deltaDeltaPlanThe delta plan indicating which chunks are obsolete.
optionsUploadOptionsOptions for the upload process. See UploadOptions

Returns

Promise<void>