multipart

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package multipart serves the JFrog CLI's multipart upload protocol, as the pinned jfrog-client-go drives it (artifactory/services/utils/ multipartupload.go): create a session, get a URL per part, PUT the parts concurrently, complete with the file's SHA-1, poll the status, and abort on failure. Once the status is FINISHED the CLI checksum-deploys the file, so a session only has to store the content and index it; the item, its properties and the package index come from that ordinary checksum deploy.

Artifactory hands out presigned S3 URLs and the object store assembles the parts. artifactweave serves the part URLs itself and keeps one blob.Store upload session per multipart upload (decision 0004), so every backend, mirror included, takes multipart uploads: parts are staged on local disk as they arrive, in any order, and appended to the blob upload in order. Only the parts that arrive ahead of a missing one wait on disk, a few times the part size with the CLI's concurrency.

Index

Constants

View Source
const (
	StatusParts      = "PARTS"
	StatusProcessing = "PROCESSING"
	StatusFinished   = "FINISHED"
	StatusRetryable  = "RETRYABLE_ERROR"
	StatusFailed     = "NON_RETRYABLE_ERROR"
	StatusAborted    = "ABORTED"
)

Statuses the CLI's status poll understands.

View Source
const Backend = "jfrog-multipart"

Backend names multipart sessions in the uploads table, so the garbage collector hands them to Reap rather than to the blob store.

View Source
const (
	// MaxPartSize bounds partSizeMB: S3's largest part, which Artifactory
	// passes the size to.
	MaxPartSize = 5 << 30
)

Variables

View Source
var (
	// ErrBadToken reports a token or part signature that does not verify.
	ErrBadToken = errors.New("multipart: invalid upload token")
	// ErrInvalid reports a malformed request.
	ErrInvalid = errors.New("multipart: invalid request")
	// ErrState reports a request the session's state does not allow, such as
	// a part after completion started.
	ErrState = errors.New("multipart: upload is not accepting this request")
	// ErrCorrupt reports a blob upload holding bytes its session cannot
	// account for.
	ErrCorrupt = errors.New("multipart: the blob upload and its session disagree")
)

Functions

This section is empty.

Types

type Service

type Service struct {
	Store store.Store
	Blobs blob.Store
	Dir   string
	// Now supplies the time; nil means time.Now.
	Now func() time.Time
	// contains filtered or unexported fields
}

Service runs multipart uploads over a metadata store and a blob store. Dir holds the staged parts, a directory per upload.

func (*Service) Abort

func (s *Service) Abort(ctx context.Context, token string) error

Abort discards an upload: its staged parts, its blob upload and its session. Content already completed stays stored.

func (*Service) Complete

func (s *Service) Complete(ctx context.Context, token, sha1 string) error

Complete starts assembling the upload, checked against sha1, and returns at once: the CLI polls Status. Completing an upload that is already finished or being completed in this process changes nothing.

func (*Service) Create

func (s *Service) Create(
	ctx context.Context,
	repo, repoPath string,
	partSizeMB int64,
	by string,
) (string, error)

Create starts an upload of repoPath in repo, whose caller by is already authorised to deploy there, and returns its token: "<id>.<secret>".

func (*Service) Finished

func (s *Service) Finished(ctx context.Context, token, by, sum string) (bool, error)

Finished reports whether token is the checksum token of a finished upload that by made of the content with SHA-256 sum. That content is indexed with no item yet, so the checksum deploy that stores the item finds no file the caller may read; this lets it through instead, for that caller and that content only. A token that opens nothing is false rather than an error, so the deploy goes on to its other checks.

func (*Service) PartURL

func (s *Service) PartURL(ctx context.Context, token string, part int) (string, error)

PartURL returns the path and query the CLI PUTs part to, relative to the server's base URL. The CLI sends that request without credentials, so the URL carries a signature for that upload and part only.

func (*Service) PutPart

func (s *Service) PutPart(
	ctx context.Context,
	id string,
	part int,
	sig string,
	body io.Reader,
) error

PutPart stages part of upload id from body and appends every part that is now next in line to the blob upload.

func (*Service) Reap

func (s *Service) Reap(ctx context.Context, u store.Upload) error

Reap discards a stale session for the garbage collector, which found it in the uploads table under Backend.

func (*Service) Status

func (s *Service) Status(ctx context.Context, token string) (Status, error)

Status reports an upload's state. A completion this process is not running was interrupted by a restart: the CLI is told to complete again.

func (*Service) Sweep

func (s *Service) Sweep(ctx context.Context) error

Sweep removes staging directories whose session is gone, which a crash between dropping a session and its parts leaves behind. The runtime runs it at startup.

type Status

type Status = wire.MultipartUploadStatus

Status is the answer to a status poll.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL