localdriver

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 12 Imported by: 1

Documentation

Overview

Package localdriver provides a local filesystem storage driver.

The local driver stores objects as files on the local filesystem. Buckets map to subdirectories under a configurable root path. Object metadata is stored in sidecar .meta.json files.

DSN format:

file:///path/to/root

Usage:

drv := localdriver.New()
drv.Open(ctx, "file:///tmp/storage")
t, err := trove.Open(drv)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LocalDriver

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

LocalDriver implements driver.Driver using the local filesystem.

func New

func New() *LocalDriver

New creates a new local filesystem driver.

func Unwrap

func Unwrap(t interface{ Driver() driver.Driver }) *LocalDriver

Unwrap extracts the typed LocalDriver from a Trove handle.

func (*LocalDriver) Close

func (d *LocalDriver) Close(_ context.Context) error

Close marks the driver as closed.

func (*LocalDriver) Copy

func (d *LocalDriver) Copy(_ context.Context, srcBucket, srcKey, dstBucket, dstKey string, opts ...driver.CopyOption) (*driver.ObjectInfo, error)

Copy copies an object within or across buckets.

func (*LocalDriver) CreateBucket

func (d *LocalDriver) CreateBucket(_ context.Context, name string, _ ...driver.BucketOption) error

CreateBucket creates a subdirectory under the root.

func (*LocalDriver) Delete

func (d *LocalDriver) Delete(_ context.Context, bucket, key string, _ ...driver.DeleteOption) error

Delete removes an object from disk.

func (*LocalDriver) DeleteBucket

func (d *LocalDriver) DeleteBucket(_ context.Context, name string) error

DeleteBucket removes a bucket subdirectory.

func (*LocalDriver) Get

func (d *LocalDriver) Get(_ context.Context, bucket, key string, _ ...driver.GetOption) (*driver.ObjectReader, error)

Get retrieves an object from disk.

func (*LocalDriver) Head

func (d *LocalDriver) Head(_ context.Context, bucket, key string) (*driver.ObjectInfo, error)

Head returns object metadata without content.

func (*LocalDriver) List

func (d *LocalDriver) List(_ context.Context, bucket string, opts ...driver.ListOption) (*driver.ObjectIterator, error)

List returns objects matching the given options.

func (*LocalDriver) ListBuckets

func (d *LocalDriver) ListBuckets(_ context.Context) ([]driver.BucketInfo, error)

ListBuckets returns all bucket directories.

func (*LocalDriver) Name

func (d *LocalDriver) Name() string

Name returns "local".

func (*LocalDriver) Open

func (d *LocalDriver) Open(_ context.Context, dsn string, _ ...driver.Option) error

Open initializes the driver with the given DSN.

Supported DSN formats:

file:///path/to/root          – absolute path
local://./relative/path       – relative path (resolved from cwd)
local:///absolute/path        – absolute path

func (*LocalDriver) Ping

func (d *LocalDriver) Ping(_ context.Context) error

Ping verifies the root directory is accessible.

func (*LocalDriver) Put

func (d *LocalDriver) Put(_ context.Context, bucket, key string, r io.Reader, opts ...driver.PutOption) (*driver.ObjectInfo, error)

Put stores an object as a file on disk.

func (*LocalDriver) RootDir

func (d *LocalDriver) RootDir() string

RootDir returns the root directory path, useful for testing and debugging.

func (*LocalDriver) SetRootDir

func (d *LocalDriver) SetRootDir(dir string)

SetRootDir directly sets the root directory without parsing a DSN. Useful for testing when you already have a temporary directory.

Jump to

Keyboard shortcuts

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