filestore

package
v0.2.21 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package filestore is the local-filesystem filecas backend: the bundled default, content-addressed, maildir-sharded (sha256/<ab>/<cd>/<hash>), zero infrastructure, directly inspectable.

Put verifies sha256(data)==hash, then writes create-if-absent: bytes to a temp file in the destination directory, then os.Link into place. os.Link fails with EEXIST if the destination exists, which IS the dedup primitive — and because the linked inode already holds the complete bytes, a reader never observes a partial object. Mirrors continuation/filestore.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileStore

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

FileStore implements filecas.Store over a directory tree.

func New

func New(dir string) (*FileStore, error)

New returns a FileStore rooted at dir, creating dir (with parents) if absent. A failure here is a startup error, not a per-request one.

func (*FileStore) BlobPath added in v0.2.19

func (fs *FileStore) BlobPath(hash string) (string, bool)

BlobPath implements filecas.PathProvider: the blob IS a local file, so zero-copy consumers can open it in place (read-only — the path is content-addressed and immutable).

func (*FileStore) Exists

func (fs *FileStore) Exists(ctx context.Context, hash string) (bool, error)

func (*FileStore) Get

func (fs *FileStore) Get(ctx context.Context, hash string) ([]byte, error)

func (*FileStore) GetReader added in v0.2.19

func (fs *FileStore) GetReader(ctx context.Context, hash string) (io.ReadCloser, int64, error)

GetReader implements filecas.ReaderGetter: an open read handle on the content-addressed file itself.

func (*FileStore) Name

func (fs *FileStore) Name() string

func (*FileStore) Put

func (fs *FileStore) Put(ctx context.Context, hash string, data []byte) error

func (*FileStore) PutReader added in v0.2.19

func (fs *FileStore) PutReader(ctx context.Context, hash string, r io.Reader, size int64) error

PutReader implements filecas.ReaderPutter: stream to a temp file in the destination directory while hashing, verify, then os.Link into place — the same never-observe-a-partial-object discipline as Put, without ever holding the blob in memory. size is advisory here; when non-negative it is cross-checked like the hash.

Jump to

Keyboard shortcuts

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