metadata

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DiffMetadata

type DiffMetadata struct {
	Type           string `json:"type"` // "added", "modified", "deleted"
	OldSize        int64  `json:"oldSize,omitempty"`
	NewSize        int64  `json:"newSize,omitempty"`
	OldModTime     int64  `json:"oldMtime,omitempty"`
	NewModTime     int64  `json:"newMtime,omitempty"`
	OldPermissions uint32 `json:"oldMode,omitempty"`
	NewPermissions uint32 `json:"newMode,omitempty"`
	OldHash        string `json:"oldHash,omitempty"`
	NewHash        string `json:"newHash,omitempty"`
	DiffRef        string `json:"diffRef,omitempty"` // Reference to diff data
}

DiffMetadata represents metadata for a file diff between snapshots

type FileMetadata

type FileMetadata struct {
	Size          int64  `json:"size"`
	ModTime       int64  `json:"mtime"`
	Permissions   uint32 `json:"mode"`
	IsDir         bool   `json:"isDir"`
	Hash          string `json:"hash,omitempty"`
	DataRef       string `json:"dataRef,omitempty"` // Reference to FlatBuffer data
	SymlinkTarget string `json:"symlinkTarget,omitempty"`
}

FileMetadata represents metadata for a file in a snapshot

type Options

type Options struct {
	AutoCommit bool
	StoreType  StoreType
}

Options for configuring the metadata store

func DefaultOptions

func DefaultOptions() Options

DefaultOptions returns the default options for the metadata store

type SnapshotMetadata

type SnapshotMetadata struct {
	ID          string    `json:"id"`
	CreatedAt   time.Time `json:"createdAt"`
	Description string    `json:"description,omitempty"`
	FileCount   int       `json:"fileCount"`
	TotalSize   int64     `json:"totalSize"`
	RootPath    string    `json:"rootPath"`
	IsHot       bool      `json:"isHot"` // Whether this snapshot is in the hot layer
}

SnapshotMetadata represents metadata for a snapshot

type Store

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

Store represents a metadata store backed by BuntDB

func New

func New(path string, options Options) (*Store, error)

New creates a new metadata store

func (*Store) AddDiffMetadata

func (s *Store) AddDiffMetadata(baseSnapshotID, targetSnapshotID, path string, metadata DiffMetadata) error

AddDiffMetadata adds diff metadata between two snapshots

func (*Store) AddFileMetadata

func (s *Store) AddFileMetadata(snapshotID, path string, metadata FileMetadata) error

AddFileMetadata adds file metadata to a snapshot

func (*Store) AddSnapshot

func (s *Store) AddSnapshot(snapshot SnapshotMetadata) error

AddSnapshot adds a new snapshot to the metadata store

func (*Store) Close

func (s *Store) Close() error

Close closes the metadata store

func (*Store) DeleteSnapshot

func (s *Store) DeleteSnapshot(id string) error

DeleteSnapshot deletes a snapshot and all its file metadata

func (*Store) FindFilesByHash

func (s *Store) FindFilesByHash(snapshotID, hash string) (map[string]FileMetadata, error)

FindFilesByHash finds files in a snapshot by hash

func (*Store) FindFilesByModTime

func (s *Store) FindFilesByModTime(snapshotID string, startTime, endTime time.Time) (map[string]FileMetadata, error)

FindFilesByModTime finds files in a snapshot by modification time range

func (*Store) FindFilesByPattern

func (s *Store) FindFilesByPattern(snapshotID, pattern string) (map[string]FileMetadata, error)

FindFilesByPattern finds files in a snapshot by pattern

func (*Store) FindFilesBySize

func (s *Store) FindFilesBySize(snapshotID string, minSize, maxSize int64) (map[string]FileMetadata, error)

FindFilesBySize finds files in a snapshot by size range

func (*Store) GetDiffMetadata

func (s *Store) GetDiffMetadata(baseSnapshotID, targetSnapshotID, path string) (DiffMetadata, error)

GetDiffMetadata retrieves diff metadata between two snapshots

func (*Store) GetFileMetadata

func (s *Store) GetFileMetadata(snapshotID, path string) (FileMetadata, error)

GetFileMetadata retrieves file metadata from a snapshot

func (*Store) GetSnapshot

func (s *Store) GetSnapshot(id string) (SnapshotMetadata, error)

GetSnapshot retrieves a snapshot from the metadata store

func (*Store) IsHotLayerEnabled

func (s *Store) IsHotLayerEnabled() bool

IsHotLayerEnabled returns whether the hot layer is enabled

func (*Store) ListDiffs

func (s *Store) ListDiffs(baseSnapshotID, targetSnapshotID string) (map[string]DiffMetadata, error)

ListDiffs lists all diffs between two snapshots

func (*Store) ListSnapshots

func (s *Store) ListSnapshots() ([]SnapshotMetadata, error)

ListSnapshots lists all snapshots in the metadata store

func (*Store) Shrink

func (s *Store) Shrink() error

Shrink shrinks the database file

type StoreType

type StoreType int

StoreType represents the type of metadata store

const (
	// NoStore means no metadata store is used (cold storage only)
	NoStore StoreType = iota
	// HotStore means a BuntDB store is used for fast querying
	HotStore
)

Jump to

Keyboard shortcuts

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