Help us shape the future of Go! Take the 2026 Go Developer Survey

packages

package
v1.27.3 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMemorySize = 32 * 1024 * 1024

Variables

This section is empty.

Functions

func KeyToRelativePath

func KeyToRelativePath(key BlobHash256Key) string

KeyToRelativePath converts the sha256 key aabb000000... to aa/bb/aabb000000...

Types

type BlobHash256Key

type BlobHash256Key string

BlobHash256Key is the key to address a blob content

func RelativePathToKey

func RelativePathToKey(relativePath string) (BlobHash256Key, error)

RelativePathToKey converts a relative path aa/bb/aabb000000... to the sha256 key aabb000000...

type BoundedFileList

type BoundedFileList struct {
	// contains filtered or unexported fields
}

BoundedFileList accumulates file names from a package archive while enforcing caps on the number of entries and their total name length, returning an error once either cap would be exceeded.

func NewBoundedFileList

func NewBoundedFileList(maxFiles, maxNameBytes int) *BoundedFileList

NewBoundedFileList creates a BoundedFileList with the given caps; a non-positive cap falls back to the corresponding default.

func (*BoundedFileList) Add

func (b *BoundedFileList) Add(name string) error

Add appends name, returning util.ErrInvalidArgument once the entry count or accumulated byte length would exceed the configured cap.

func (*BoundedFileList) Files

func (b *BoundedFileList) Files() []string

Files returns the accumulated file names.

type ContentStore

type ContentStore struct {
	// contains filtered or unexported fields
}

ContentStore is a wrapper around ObjectStorage

func NewContentStore

func NewContentStore() *ContentStore

NewContentStore creates the default package store

func (*ContentStore) Delete

func (s *ContentStore) Delete(key BlobHash256Key) error

Delete deletes a package blob

func (*ContentStore) GetServeDirectURL

func (s *ContentStore) GetServeDirectURL(key BlobHash256Key, filename, method string, reqParams *storage.ServeDirectOptions) (*url.URL, error)

func (*ContentStore) Has

func (s *ContentStore) Has(key BlobHash256Key) error

FIXME: Workaround to be removed in v1.20 https://github.com/go-gitea/gitea/issues/19586

func (*ContentStore) OpenBlob

func (s *ContentStore) OpenBlob(key BlobHash256Key) (storage.Object, error)

func (*ContentStore) Save

func (s *ContentStore) Save(key BlobHash256Key, r io.Reader, size int64) error

Save stores a package blob

func (*ContentStore) ShouldServeDirect

func (s *ContentStore) ShouldServeDirect() bool

type HashSummer

type HashSummer interface {
	Sums() (hashMD5, hashSHA1, hashSHA256, hashSHA512 []byte)
}

HashSummer provide a Sums method

type HashedBuffer

type HashedBuffer struct {
	*filebuffer.FileBackedBuffer
	// contains filtered or unexported fields
}

HashedBuffer is buffer which calculates multiple checksums

func CreateHashedBufferFromReader

func CreateHashedBufferFromReader(r io.Reader) (*HashedBuffer, error)

CreateHashedBufferFromReader creates a hashed buffer with the default memory size and copies the provided reader data into it.

func CreateHashedBufferFromReaderWithSize

func CreateHashedBufferFromReaderWithSize(r io.Reader, maxMemorySize int) (*HashedBuffer, error)

CreateHashedBufferFromReaderWithSize creates a hashed buffer and copies the provided reader data into it.

func NewHashedBuffer

func NewHashedBuffer() (*HashedBuffer, error)

NewHashedBuffer creates a hashed buffer with the default memory size

func NewHashedBufferWithSize

func NewHashedBufferWithSize(maxMemorySize int) (*HashedBuffer, error)

NewHashedBufferWithSize creates a hashed buffer with a specific memory size

func (*HashedBuffer) Sums

func (b *HashedBuffer) Sums() (hashMD5, hashSHA1, hashSHA256, hashSHA512 []byte)

Sums gets the MD5, SHA1, SHA256 and SHA512 checksums of the data

func (*HashedBuffer) Write

func (b *HashedBuffer) Write(p []byte) (int, error)

Write implements io.Writer

type HashedSizeReader

type HashedSizeReader interface {
	io.Reader
	HashSummer
	Size() int64
}

HashedSizeReader provide methods to read, sum hashes and a Size method

type MultiHasher

type MultiHasher struct {
	// contains filtered or unexported fields
}

MultiHasher calculates multiple checksums

func NewMultiHasher

func NewMultiHasher() *MultiHasher

NewMultiHasher creates a multi hasher

func (*MultiHasher) MarshalBinary

func (h *MultiHasher) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler

func (*MultiHasher) Sums

func (h *MultiHasher) Sums() (hashMD5, hashSHA1, hashSHA256, hashSHA512 []byte)

Sums gets the MD5, SHA1, SHA256 and SHA512 checksums of the data

func (*MultiHasher) UnmarshalBinary

func (h *MultiHasher) UnmarshalBinary(b []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler

func (*MultiHasher) Write

func (h *MultiHasher) Write(p []byte) (int, error)

Write implements io.Writer

Jump to

Keyboard shortcuts

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