filemeta

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2023 License: GPL-3.0 Imports: 17 Imported by: 2

README

filemeta

Extraction of file metadata, including the hash, stored to extended attributes

Documentation

Index

Constants

View Source
const HashSize = blake2b.Size256

Variables

This section is empty.

Functions

func ReadCustom

func ReadCustom(fileName string, attrName string, data proto.Message) error

func SyncOperations

func SyncOperations(op Op) (func(string) Data, func())

func WriteCustom

func WriteCustom(fileName string, attrName string, data proto.Message) error

Types

type Async

type Async struct {
	FileIn  chan string
	DataOut chan Data
}

func AsyncMono

func AsyncMono(op Op) Async

func AsyncOperations

func AsyncOperations(op Op, probeThreads int, hashThreads int) Async

type Attr

type Attr struct {
	Size   int64
	TimeNs int64
	Hash   []byte
}

type Data

type Data struct {
	sys.FileInfo
	Hash         []byte
	Error        error
	Operation    Op
	Hashed       bool // the file has just been hashed
	Changed      bool // the file had attributes, but they are no longer valid
	VerifyFailed bool
	// contains filtered or unexported fields
}

func Get

func Get(fileName string) Data

Gets the metadata if available; if not available data.Attr is nil

func Inspect

func Inspect(fileName string) Data

Gets the metadata if available; returns an error if not

func Operation

func Operation(op Op, fileName string) (data Data)

func Refresh

func Refresh(fileName string) Data

Gets the metadata, refreshing it if necessary

func Verify

func Verify(fileName string) Data

Like get, but additional it verifies the hash (scrub)

func (*Data) GetAttr

func (d *Data) GetAttr() Attr

func (*Data) GetModTime

func (d *Data) GetModTime() time.Time

func (*Data) Rename

func (d *Data) Rename(newPath string) (err error)

func (*Data) SetModTime

func (d *Data) SetModTime(tim time.Time) (err error)

type FetchFunc

type FetchFunc func(fileName string) Data

type FileWriter

type FileWriter struct {
	Open  func(fileName string, fileFlags int, filePerm os.FileMode) error
	Write func([]byte) error
	Close func(fileTimeNs int64) (Attr, error)
}

func NewFileWriter

func NewFileWriter() FileWriter

type HashKey

type HashKey [HashSize]byte

func ToHashKey

func ToHashKey(x []byte) (k HashKey)

type Op

type Op int8
const (
	OpGet Op = iota
	OpVerify
	OpRefresh
	OpInspect
)

func (Op) String

func (op Op) String() string

Jump to

Keyboard shortcuts

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