local

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2025 License: BSD-2-Clause Imports: 20 Imported by: 0

Documentation

Overview

Package local implements repository storage in a local directory.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFactory

func NewFactory() location.Factory

Types

type Config

type Config struct {
	Path string

	Connections uint `option:"connections" help:"set a limit for the number of concurrent operations (default: 2)"`
}

Config holds all information needed to open a local repository.

func NewConfig

func NewConfig() Config

NewConfig returns a new config with default options applied.

func ParseConfig

func ParseConfig(s string) (*Config, error)

ParseConfig parses a local backend config.

type Local

type Local struct {
	Config
	layout.Layout
	util.Modes
}

Local is a backend in a local directory.

func Create

func Create(_ context.Context, cfg Config) (*Local, error)

Create creates all the necessary files and directories for a new local backend at dir. Afterwards a new config blob should be created.

func Open

func Open(_ context.Context, cfg Config) (*Local, error)

Open opens the local backend as specified by config.

func (*Local) Close

func (b *Local) Close() error

Close closes all open files.

func (*Local) Delete

func (b *Local) Delete(_ context.Context) error

Delete removes the repository and all files.

func (*Local) Hasher

func (b *Local) Hasher() hash.Hash

Hasher may return a hash function for calculating a content hash for the backend

func (*Local) IsNotExist

func (b *Local) IsNotExist(err error) bool

IsNotExist returns true if the error is caused by a non existing file.

func (*Local) IsPermanentError added in v0.17.0

func (b *Local) IsPermanentError(err error) bool

func (*Local) List

func (b *Local) List(ctx context.Context, t backend.FileType, fn func(backend.FileInfo) error) (err error)

List runs fn for each file in the backend which has the type t. When an error occurs (or fn returns an error), List stops and returns it.

func (*Local) Load

func (b *Local) Load(ctx context.Context, h backend.Handle, length int, offset int64, fn func(rd io.Reader) error) error

Load runs fn with a reader that yields the contents of the file at h at the given offset.

func (*Local) Properties added in v0.18.0

func (b *Local) Properties() backend.Properties

func (*Local) Remove

func (b *Local) Remove(_ context.Context, h backend.Handle) error

Remove removes the blob with the given name and type.

func (*Local) Save

func (b *Local) Save(_ context.Context, h backend.Handle, rd backend.RewindReader) (err error)

Save stores data in the backend at the handle.

func (*Local) Stat

Stat returns information about a blob.

func (*Local) Warmup added in v0.18.0

func (b *Local) Warmup(_ context.Context, _ []backend.Handle) ([]backend.Handle, error)

Warmup not implemented

func (*Local) WarmupWait added in v0.18.0

func (b *Local) WarmupWait(_ context.Context, _ []backend.Handle) error

Jump to

Keyboard shortcuts

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