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 ¶
- type FileStore
- func (fs *FileStore) BlobPath(hash string) (string, bool)
- func (fs *FileStore) Exists(ctx context.Context, hash string) (bool, error)
- func (fs *FileStore) Get(ctx context.Context, hash string) ([]byte, error)
- func (fs *FileStore) GetReader(ctx context.Context, hash string) (io.ReadCloser, int64, error)
- func (fs *FileStore) Name() string
- func (fs *FileStore) Put(ctx context.Context, hash string, data []byte) error
- func (fs *FileStore) PutReader(ctx context.Context, hash string, r io.Reader, size int64) error
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 ¶
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
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) GetReader ¶ added in v0.2.19
GetReader implements filecas.ReaderGetter: an open read handle on the content-addressed file itself.
func (*FileStore) PutReader ¶ added in v0.2.19
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.