diff

package
v0.0.0-...-a14cbf1 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintLargestDiffs

func PrintLargestDiffs(limit int, sf ScanDiff)

func WalkAddTreeDiff

func WalkAddTreeDiff(t *tree.FileTree, d *ScanDiff, newTreeAllHash *[]byte, addedTrees []TreeDiff, addedFiles []FileDiff) (removeThisTree bool)

Adds a `TreeDiff` onto a `FileTree`, returning the resultant `FileTree`

NOTE: Assumes the `FileTree` and `TreeDiff` have the same root

Types

type DiffType

type DiffType int64

type FileDiff

type FileDiff struct {
	NewerName        string
	NewerErr         string
	Type             DiffType
	HashDiff         utility.HashLocation
	SizeDiff         int64
	LastModifiedDiff time.Duration
}

Contains the differences between two `File`s

func (*FileDiff) Empty

func (f *FileDiff) Empty() bool

func (*FileDiff) Equals

func (f *FileDiff) Equals(b FileDiff) bool

type ScanDiff

type ScanDiff struct {
	AllHash []byte // Only populated at depth == 0
	Trees   map[string]TreeDiff
	Files   map[string]FileDiff
}

The "root" ds for a scan diff, contains all detected file/tree differences, their paths (as map keys) and an array containing all new file hash values

func AddDiffsForPath

func AddDiffsForPath(path string, firstIdx, lastIdx int) (ScanDiff, error)

For a given path, and each index between `firstIdx` and `lastIdx` (of recorded diffs) accumulate the "diff"s into a single "diff"

TODO: I think this is missing some error conditions

func CompareTrees

func CompareTrees(a, b *tree.FileTree) ScanDiff

Compare two trees and store their differences in an output `ScanDiff`

func ReadBinary

func ReadBinary(path string) (ScanDiff, error)

func (*ScanDiff) AddDiff

func (s *ScanDiff) AddDiff(new ScanDiff, thisAllHash *[]byte)

Adds the changes in `new` to diff `s`. So that we can do, for example:

s1 + diff(s1, s2) + diff(s2, s3) == s3

TODO: Currently not working

func (*ScanDiff) Empty

func (s *ScanDiff) Empty() bool

func (*ScanDiff) Equals

func (a *ScanDiff) Equals(b ScanDiff) bool

func (*ScanDiff) WriteBinary

func (d *ScanDiff) WriteBinary(path string) error

type TreeDiff

type TreeDiff struct {
	DiffCompleted time.Time
	Comprehensive bool
	Type          DiffType

	// Non-recursive data
	OriginalPath     string
	NewerPath        string
	DepthDiff        int
	ErrStringsDiff   []string
	FilesDiff        []FileDiff
	FilesDiffIndices []int
	LastVisitedDiff  time.Duration
	TimeTakenDiff    time.Duration

	LastModifiedDiffDirect  time.Duration
	SizeDiffDirect          int64
	NumFilesTotalDiffDirect int64

	// Recursive data
	SubTreesDiff        []TreeDiff
	SubTreesDiffIndices []int

	AllHash       []byte // Only populated at depth == 0
	AllHashOffset int64
}

Captures the differences between two `FileTree`s

func (*TreeDiff) Empty

func (t *TreeDiff) Empty() bool

func (*TreeDiff) Equals

func (t *TreeDiff) Equals(b TreeDiff) bool

Jump to

Keyboard shortcuts

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