fingerprint

package
v0.110.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultSize = 1000 // bytes
View Source
const MinSize = 16 // bytes

Variables

This section is empty.

Functions

This section is empty.

Types

type Fingerprint

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

Fingerprint is used to identify a file A file's fingerprint is the first N bytes of the file

func New

func New(first []byte) *Fingerprint

func NewFromFile added in v0.96.0

func NewFromFile(file *os.File, size int) (*Fingerprint, error)

func (Fingerprint) Copy

func (f Fingerprint) Copy() *Fingerprint

Copy creates a new copy of the fingerprint

func (Fingerprint) Equal

func (f Fingerprint) Equal(other *Fingerprint) bool

Equal returns true if the fingerprints have the same FirstBytes, false otherwise. This does not compare other aspects of the fingerprints because the primary purpose of a fingerprint is to convey a unique identity, and only the FirstBytes field contributes to this goal.

func (*Fingerprint) Len added in v0.96.0

func (f *Fingerprint) Len() int

func (*Fingerprint) MarshalJSON added in v0.96.0

func (f *Fingerprint) MarshalJSON() ([]byte, error)

func (Fingerprint) StartsWith

func (f Fingerprint) StartsWith(old *Fingerprint) bool

StartsWith returns true if the fingerprints are the same or if the new fingerprint starts with the old one This is important functionality for tracking new files, since their initial size is typically less than that of a fingerprint. As the file grows, its fingerprint is updated until it reaches a maximum size, as configured on the operator

func (*Fingerprint) UnmarshalJSON added in v0.96.0

func (f *Fingerprint) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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