metadata

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound      = errors.New("metadata not found")
	ErrAlreadyExists = errors.New("metadata already exists")
	ErrForbidden     = errors.New("access forbidden")
)

Common metadata errors

Functions

This section is empty.

Types

type ErasureFileInfo added in v1.1.0

type ErasureFileInfo struct {
	FilePath     string             `json:"file_path"`
	OriginalSize int64              `json:"original_size"`
	DataShards   int                `json:"data_shards"`
	ParityShards int                `json:"parity_shards"`
	ShardSize    int64              `json:"shard_size"`
	Shards       []ErasureShardInfo `json:"shards"`
}

ErasureFileInfo holds erasure coding metadata (imported by metadata stores)

type ErasureMetadataStore added in v1.1.0

type ErasureMetadataStore interface {
	CreateErasureInfo(ctx context.Context, filePath string, info *ErasureFileInfo) error
	GetErasureInfo(ctx context.Context, filePath string) (*ErasureFileInfo, error)
	DeleteErasureInfo(ctx context.Context, filePath string) error
}

ErasureMetadataStore defines the interface for erasure coding metadata operations.

type ErasureShardInfo added in v1.1.0

type ErasureShardInfo struct {
	Index       int    `json:"index"`
	InstanceID  string `json:"instance_id"`
	BackendType string `json:"backend_type"`
	Path        string `json:"path"`
	Size        int64  `json:"size"`
	Checksum    string `json:"checksum"`
}

ErasureShardInfo describes a single shard's storage location.

type Metadata

type Metadata struct {
	ID               int64     `json:"id"`
	ParentID         *int64    `json:"parent_id"`
	Name             string    `json:"name"`
	Path             string    `json:"path"`
	Type             string    `json:"type"` // "file" or "directory"
	Size             int64     `json:"size"`
	Mode             string    `json:"mode"`  // Permission mode string like "0644"
	Owner            string    `json:"owner"` // App-level owner (user ID string, e.g. "api-user-0"). NOT an OS user.
	ATime            time.Time `json:"atime"`
	MTime            time.Time `json:"mtime"`
	CTime            time.Time `json:"ctime"`
	BackendType      string    `json:"backend_type"`       // "localfs", "s3", or "erasure"
	ErasureCoded     bool      `json:"erasure_coded"`      // true if file is erasure-coded
	CallFSInstanceID *string   `json:"callfs_instance_id"` // Instance ID for the server that owns this file
	SymlinkTarget    *string   `json:"symlink_target"`     // For future symlink support
	CreatedAt        time.Time `json:"created_at"`
	UpdatedAt        time.Time `json:"updated_at"`
}

Metadata represents filesystem metadata for an inode

type SingleUseLink struct {
	ID            int64      `json:"id"`
	Token         string     `json:"token"`
	FilePath      string     `json:"file_path"`
	Status        string     `json:"status"` // "active", "used", "expired"
	ExpiresAt     time.Time  `json:"expires_at"`
	UsedAt        *time.Time `json:"used_at"`
	UsedByIP      *string    `json:"used_by_ip"`
	HMACSignature string     `json:"hmac_signature"`
	CreatedAt     time.Time  `json:"created_at"`
	UpdatedAt     time.Time  `json:"updated_at"`
}

SingleUseLink represents a secure, single-use download link

type Store

type Store interface {
	// Get retrieves metadata for a file or directory by path
	Get(ctx context.Context, path string) (*Metadata, error)

	// Create creates a new inode entry
	Create(ctx context.Context, md *Metadata) error

	// Update updates an existing inode entry
	Update(ctx context.Context, md *Metadata) error

	// Delete removes an inode entry by path
	Delete(ctx context.Context, path string) error

	// ListChildren returns all children of a directory
	ListChildren(ctx context.Context, parentPath string) ([]*Metadata, error)

	// GetSingleUseLink retrieves a single-use link by token
	GetSingleUseLink(ctx context.Context, token string) (*SingleUseLink, error)

	// CreateSingleUseLink creates a new single-use link
	CreateSingleUseLink(ctx context.Context, link *SingleUseLink) error

	// UpdateSingleUseLink atomically updates a single-use link status
	UpdateSingleUseLink(ctx context.Context, token string, status string, usedAt *time.Time, usedByIP *string) error

	// CleanupExpiredLinks removes expired single-use links and returns count of removed links
	CleanupExpiredLinks(ctx context.Context, before time.Time) (int, error)

	// CleanupUsedLinks removes used single-use links older than the given time and returns count of removed links
	CleanupUsedLinks(ctx context.Context, olderThan time.Time) (int, error)

	// Close closes the metadata store connection
	Close() error
}

Store defines the interface for metadata storage operations

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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