storage

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2023 License: Unlicense Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEmptyReader can be returned when a reader provided to create file is empty.
	ErrEmptyReader = errors.New("empty reader")
	// ErrInvalidHash can be returned for invalid hash input.
	// Use only stringified hashes returned by this implementation.
	ErrInvalidHash = errors.New("invalid hash")
)

Functions

This section is empty.

Types

type Storage

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

Storage is a dir wrapper to store files by their content hashes (SHA512).

func New

func New(tempDir, dataDir string, dirPerm os.FileMode) *Storage

New constructs a new storage with given params.

func (*Storage) Create

func (s *Storage) Create(r io.Reader) (string, error)

Create creates a local file from provided reader.

func (*Storage) Path

func (s *Storage) Path(hash string) (string, error)

Path builds a data file path for given hash. It does not check for file existence.

func (*Storage) Remove added in v0.0.4

func (s *Storage) Remove(hash string) error

Remove removes the file identified by hash and may perform additional cleanup.

Jump to

Keyboard shortcuts

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