filestore

package
v0.2.49 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package filestore is the local-filesystem drive object backend: the bundled default, zero infrastructure, directly inspectable.

A put is atomic: content is written to a temp file in the destination directory, then renamed into place, so a reader never observes a partial object and a failed put leaves nothing at the key. Keys are the ids the drive store mints — every segment must already be `[A-Za-z0-9._-]` and not only dots; this backend REJECTS anything else rather than sanitizing, because a key it did not expect is a bug, not input.

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 drive.ObjectStore 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) Copy

func (fs *FileStore) Copy(ctx context.Context, from, to string) error

Copy implements drive.ObjectCopier: a hard link when the filesystem allows it (the object is immutable, so sharing the inode is safe), else a byte copy.

func (*FileStore) Delete

func (fs *FileStore) Delete(ctx context.Context, key string) error

Delete implements drive.ObjectStore (idempotent). Empty parent directories are removed up to the root so a deleted resource leaves no trace.

func (*FileStore) Get

Get implements drive.ObjectStore.

func (*FileStore) List

func (fs *FileStore) List(ctx context.Context, prefix string, fn func(key string, info drive.ObjectInfo) error) error

List implements drive.ObjectStore: every regular file under prefix (a key prefix on segment boundaries; "" for all), skipping in-flight temp files.

func (*FileStore) Name

func (fs *FileStore) Name() string

Name implements drive.ObjectStore.

func (*FileStore) Put

func (fs *FileStore) Put(ctx context.Context, key string, r io.Reader, size int64, contentType string) error

Put implements drive.ObjectStore: temp file in the destination directory, then rename (atomic on POSIX). No fsync, per the chassis posture.

func (*FileStore) Stat

func (fs *FileStore) Stat(ctx context.Context, key string) (drive.ObjectInfo, error)

Stat implements drive.ObjectStore.

Jump to

Keyboard shortcuts

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