vfsstore

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitSchema

func InitSchema(ctx context.Context, exec libdbexec.Exec) error

InitSchema creates the VFS tables and indexes if they do not already exist.

Types

type Blob

type Blob struct {
	ID        string    `json:"id"`
	Meta      []byte    `json:"meta"`
	Data      []byte    `json:"data"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

Blob holds binary data associated with a file.

type ChildEntry

type ChildEntry struct {
	ID        string
	Name      string
	IsFolder  bool
	Type      string
	Meta      []byte
	BlobsID   string
	CreatedAt time.Time
	UpdatedAt time.Time
}

ChildEntry holds the name and file metadata for a single directory child. Returned by ListChildrenByParentID to avoid per-child tree walks.

type File

type File struct {
	ID        string    `json:"id"`
	Type      string    `json:"type"`
	Meta      []byte    `json:"meta"`
	BlobsID   string    `json:"blobsId,omitempty"`
	IsFolder  bool      `json:"isFolder"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

File represents a logical file or folder in the VFS.

type FileTreeEntry

type FileTreeEntry struct {
	ID        string    `json:"id"`
	ParentID  string    `json:"parentId,omitempty"`
	Name      string    `json:"name"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

FileTreeEntry represents a node in the hierarchical file tree.

type Store

type Store interface {
	// FileTree operations
	ListFileIDsByParentID(ctx context.Context, parentID string) ([]string, error)
	// ListChildrenByParentID returns name + metadata for all children in one JOIN query.
	ListChildrenByParentID(ctx context.Context, parentID string) ([]ChildEntry, error)
	ListFileIDsByName(ctx context.Context, parentID, name string) ([]string, error)
	GetFileParentID(ctx context.Context, id string) (string, error)
	GetFileNameByID(ctx context.Context, id string) (string, error)
	CreateFileNameID(ctx context.Context, id, parentID, name string) error
	DeleteFileNameID(ctx context.Context, id string) error
	UpdateFileNameByID(ctx context.Context, id, name string) error
	UpdateFileParentID(ctx context.Context, id, newParentID string) error

	// File operations
	CreateFile(ctx context.Context, file *File) error
	GetFileByID(ctx context.Context, id string) (*File, error)
	UpdateFile(ctx context.Context, file *File) error
	DeleteFile(ctx context.Context, id string) error
	ListFiles(ctx context.Context) ([]string, error)
	EstimateFileCount(ctx context.Context) (int64, error)
	EnforceMaxFileCount(ctx context.Context, maxCount int64) error

	// Blob operations
	CreateBlob(ctx context.Context, blob *Blob) error
	GetBlobByID(ctx context.Context, id string) (*Blob, error)
	DeleteBlob(ctx context.Context, id string) error
	// UpdateBlob updates blob data and meta in-place without delete+insert churn.
	UpdateBlob(ctx context.Context, id string, data, meta []byte) error
}

Store defines all persistence operations for the VFS.

func New

func New(exec libdb.Exec) Store

New creates a new VFS store instance.

Jump to

Keyboard shortcuts

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