Documentation ¶
Index ¶
Constants ¶
const DefaultSize = 1000 // bytes
const MinSize = 16 // bytes
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Fingerprint ¶
type Fingerprint struct {
FirstBytes []byte
}
Fingerprint is used to identify a file A file's fingerprint is the first N bytes of the file
func New ¶
func New(file *os.File, size int) (*Fingerprint, error)
New creates a new fingerprint from an open file
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) 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