luci: Index | Files

package upload

import ""


Package Files

id.go operation.go

func NewOpID Uses

func NewOpID(ctx context.Context) (int64, error)

NewOpID returns new unique upload operation ID.

func UnwrapOpID Uses

func UnwrapOpID(ctx context.Context, token string, caller identity.Identity) (int64, error)

UnwrapOpID extracts upload operation ID from a HMAC-protected string.

func WrapOpID Uses

func WrapOpID(ctx context.Context, id int64, caller identity.Identity) (string, error)

WrapOpID returns HMAC-protected string that embeds upload operation ID.

The string is bound to the given caller, i.e UnwrapOpID will correctly validate HMAC only if it receives the exact same caller.

type Operation Uses

type Operation struct {
    ID  int64 `gae:"$id"`

    Status api.UploadStatus
    Error  string `gae:",noindex"` // error message if the verification failed

    TempGSPath string `gae:",noindex"` // the GS path to where the client uploads
    UploadURL  string `gae:",noindex"` // resumable upload URL

    HashAlgo  api.HashAlgo // the algo to use to verify the uploaded content
    HexDigest string       // the expected content digest or "" if not known

    CreatedBy identity.Identity // who initiated the upload, FYI
    CreatedTS time.Time         // when the upload was initiated, FYI
    UpdatedTS time.Time         // last time this entity was saved, FYI
    // contains filtered or unexported fields

Operation is a datastore entity that represents an upload.

func (*Operation) Advance Uses

func (op *Operation) Advance(ctx context.Context, cb func(context.Context, *Operation) error) (*Operation, error)

Advance transactionally updates the entity (by calling the callback) if its Status in the datastore is still same as op.Status.

If the entity in the datastore has different Status, silently skips calling the callback. It means the entity has been updated concurrently. This works because all Operation mutations actually switch statuses and the Operation state machine can "roll" only in one direction.

Returns the most recent state of the operation (whether it was mutated just now by the callback or not). 'op' itself is kept intact.

Returns only transient errors. All callback errors are tagged as transient as well.

func (*Operation) ToProto Uses

func (op *Operation) ToProto(wrappedID string) *api.UploadOperation

ToProto constructs UploadOperation proto message.

The caller must prepare the ID in advance using WrapOpID.

Package upload imports 10 packages (graph) and is imported by 1 packages. Updated 2020-11-26. Refresh now. Tools for package owners.