Skip to main content

UploadPipeline

UploadPipeline is the base abstract class responsible for managing the file upload flow in rac-delta. It provides the core structure for notifying progress, handling state changes, and coordinating uploads, but does not implement the actual storage logic.

This class is meant to be extended by specialized pipelines such as HashUploadPipeline and UrlUploadPipeline.


Methods

Shared base methods.

MethodReturnsDescription
updateProgress(value, state, speed?, options?)voidCallback for progress such as uploading or deleting files.
changeState(state, options?)voidCallback to notify state changes.

UploadOptions

The UploadOptions object allows you to customize the behavior of an upload:

export interface UploadOptions {
force?: boolean;
requireRemoteIndex?: boolean;
ignorePatterns?: string[];
onProgress?: (type: 'upload' | 'deleting', progress: number, speed?: number) => void;
onStateChange?: (state: UploadState) => void;
}
PropertyTypeDescription
forcebooleanIf true, forces complete upload even if remote index exists. If false, only new and modified chunks will be uploaded.
requireRemoteIndexbooleanIf true and no remote index found, abort upload. If false (default), uploads everything if no remote index found.
ignorePatternsstring[]Files or directories that must be ignored when creating the rd-index.json.
onProgress(type, progress, speed?) => voidOptional callback to inform progress.
onStateChange(state) => voidOptional callback for state changes.

UploadState

Type of state that can be returned with the onStateChange callback:

export type UploadState = 'uploading' | 'comparing' | 'cleaning' | 'finalizing' | 'scanning';

Method details

updateProgress(value, state, speed?, options?)

Used to call given onProgress callback inside options.

Parameters

NameTypeDescription
valuenumberProgress value (0 - 100)
stateupload | deletingWhich operation is being monitorized
speed?numberSpeed in bytes/s (only for state upload)
options?UploadOptionsOptions object, see UploadOptions above for more info (this method only uses callback)

Returns

void


changeState(state, options?)

Used to call given onStateChange callback inside options.

Parameters

NameTypeDescription
stateUploadStateState of the flow, see UploadState above.
options?UploadOptionsOptions object, see UploadOptions above for more info (this method only uses callback)

Returns

void