storage

package
v0.0.0-...-363ef37 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDirPerm  = 0755
	DefaultFilePerm = 0644
	MetadataSuffix  = ".meta"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Metadata

type Metadata struct {
	LastModified time.Time `json:"last_modified"`
	Hash         string    `json:"hash"`
	Size         int64     `json:"size"`
	DownloadedAt time.Time `json:"downloaded_at"`
}

Metadata tracks download state and verification information.

type Storage

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

Storage manages OSV data storage and metadata tracking.

func New

func New(dataDir string) (*Storage, error)

New creates a new Storage instance.

func (*Storage) ComputeHash

func (s *Storage) ComputeHash(filePath string) (string, error)

ComputeHash computes SHA256 hash of a file.

func (*Storage) FileExists

func (s *Storage) FileExists(filePath string) bool

FileExists checks if a file exists.

func (*Storage) GetDataPath

func (s *Storage) GetDataPath(resource string) string

GetDataPath returns the path to the data file for a given resource.

func (*Storage) GetFileSize

func (s *Storage) GetFileSize(filePath string) (int64, error)

GetFileSize returns the size of a file.

func (*Storage) GetMetadataPath

func (s *Storage) GetMetadataPath(resource string) string

GetMetadataPath returns the path to the metadata file for a given resource.

func (*Storage) IsStale

func (s *Storage) IsStale(resource string, currentHash string, currentModTime time.Time, maxAge time.Duration) (bool, error)

IsStale checks if the stored data is stale based on metadata and current time.

func (*Storage) LoadMetadata

func (s *Storage) LoadMetadata(resource string) (*Metadata, error)

LoadMetadata loads metadata for a resource.

func (*Storage) SaveMetadata

func (s *Storage) SaveMetadata(resource string, meta *Metadata) error

SaveMetadata saves metadata for a resource.

Jump to

Keyboard shortcuts

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