filemeta

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2023 License: GPL-3.0 Imports: 20 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

View Source
var File_filemeta_proto protoreflect.FileDescriptor

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 Attributes added in v0.1.1

type Attributes struct {
	Hash   []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"`
	TimeNs int64  `protobuf:"fixed64,2,opt,name=timeNs,proto3" json:"timeNs,omitempty"`
	Size   int64  `protobuf:"varint,3,opt,name=size,proto3" json:"size,omitempty"`
	// contains filtered or unexported fields
}

func (*Attributes) Descriptor deprecated added in v0.1.1

func (*Attributes) Descriptor() ([]byte, []int)

Deprecated: Use Attributes.ProtoReflect.Descriptor instead.

func (*Attributes) GetHash added in v0.1.1

func (x *Attributes) GetHash() []byte

func (*Attributes) GetSize added in v0.1.1

func (x *Attributes) GetSize() int64

func (*Attributes) GetTimeNs added in v0.1.1

func (x *Attributes) GetTimeNs() int64

func (*Attributes) ProtoMessage added in v0.1.1

func (*Attributes) ProtoMessage()

func (*Attributes) ProtoReflect added in v0.1.1

func (x *Attributes) ProtoReflect() protoreflect.Message

func (*Attributes) Reset added in v0.1.1

func (x *Attributes) Reset()

func (*Attributes) String added in v0.1.1

func (x *Attributes) String() string

func (*Attributes) Time added in v0.1.1

func (attr *Attributes) Time() time.Time

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