Documentation
¶
Index ¶
- Constants
- type Metadata
- type Storage
- func (s *Storage) ComputeHash(filePath string) (string, error)
- func (s *Storage) FileExists(filePath string) bool
- func (s *Storage) GetDataPath(resource string) string
- func (s *Storage) GetFileSize(filePath string) (int64, error)
- func (s *Storage) GetMetadataPath(resource string) string
- func (s *Storage) IsStale(resource string, currentHash string, currentModTime time.Time, ...) (bool, error)
- func (s *Storage) LoadMetadata(resource string) (*Metadata, error)
- func (s *Storage) SaveMetadata(resource string, meta *Metadata) error
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 (*Storage) ComputeHash ¶
ComputeHash computes SHA256 hash of a file.
func (*Storage) FileExists ¶
FileExists checks if a file exists.
func (*Storage) GetDataPath ¶
GetDataPath returns the path to the data file for a given resource.
func (*Storage) GetFileSize ¶
GetFileSize returns the size of a file.
func (*Storage) GetMetadataPath ¶
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 ¶
LoadMetadata loads metadata for a resource.
Click to show internal directories.
Click to hide internal directories.