filemetadata

package
v0.0.0-...-8ff3cc7 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: Apache-2.0 Imports: 10 Imported by: 24

Documentation

Overview

Package filemetadata contains types of metadata for files, to be used for caching.

Index

Constants

This section is empty.

Variables

View Source
var (
	// XattrDigestName is the xattr name for the object digest.
	XattrDigestName string
	// XattrAccess is the object to control access of XattrDigestName.
	XattrAccess xattributeAccessorInterface = xattributeAccessor{}
)

Functions

func ResetGlobalCache

func ResetGlobalCache()

ResetGlobalCache clears the cache globally. Applies to all Cache instances created by NewSingleFlightCache.

Types

type Cache

type Cache interface {
	Get(path string) *Metadata
	Delete(filename string) error
	Update(path string, cacheEntry *Metadata) error
	GetCacheHits() uint64
	GetCacheMisses() uint64
}

Cache is a cache for file contents->Metadata.

func NewNoopCache

func NewNoopCache() Cache

NewNoopCache returns a cache that doesn't cache (evaluates on every Get).

func NewSingleFlightCache

func NewSingleFlightCache() Cache

NewSingleFlightCache returns a singleton-backed in-memory cache, with no validation.

type FileError

type FileError struct {
	IsNotFound bool
	Err        error
}

FileError is the error returned by the Compute function.

func (*FileError) Error

func (e *FileError) Error() string

Error returns the error message.

type Metadata

type Metadata struct {
	Digest       digest.Digest
	IsExecutable bool
	IsDirectory  bool
	MTime        time.Time
	Err          error
	Symlink      *SymlinkMetadata
}

Metadata contains details for a particular file.

func Compute

func Compute(filename string) *Metadata

Compute computes a Metadata from a given file path. If an error is returned, it will be of type *FileError.

type SymlinkMetadata

type SymlinkMetadata struct {
	Target     string
	IsDangling bool
}

SymlinkMetadata contains details if the given path is a symlink.

Jump to

Keyboard shortcuts

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