Documentation
¶
Overview ¶
Package diff provides the functionality for ajfs diff command.
Index ¶
- Constants
- Variables
- func Compare(lhsPath string, rhsPath string, includeFilters []FilterFlags, ...) error
- func CompareDatabases(lhs *db.DatabaseFile, rhs *db.DatabaseFile, onlyLHS bool, fn CompareFn) error
- func Run(cfg Config) error
- type ChangedFlags
- type CompareFn
- type Config
- type Diff
- type DiffStats
- type FilterFlags
- type Type
Constants ¶
const ( ChangedNothing = 0 // Nothing changed ChangedMode = 1 << iota // The path's type and or permissions has changed ChangedSize // The size has changed ChangedModTime // The last modification time has changed ChangedHash // The hash is different )
const ( FilterNoOp = 0 // Don't apply a filter FilterDirs = 1 << iota // Directories FilterFiles // Files FilterTypeLeft // LHS only (mutually exclusive with FilterOnlyRight) FilterTypeRight // RHS only FilterTypeChanged // Both sides but has changes FilterChangedMode // The path's type and or permissions has changed FilterChangedSize // The size has changed FilterChangedModTime // The last modification time has changed FilterChangedHash // The hash is different FilterChangedMask = FilterChangedMode | FilterChangedSize | FilterChangedModTime | FilterChangedHash )
Variables ¶
var SkipAll = errors.New("skip all") //nolint:staticcheck //ST1012: not an error and is more readable
Indicates to Compare to stop processing differences.
Functions ¶
func Compare ¶
func Compare(lhsPath string, rhsPath string, includeFilters []FilterFlags, excludeFilters []FilterFlags, fn CompareFn) error
Compare the differences between two ajfs database files. fn Will be called for each difference that is found. If fn returns SkipAll then the process will be stopped and nil will be returned as the error.
func CompareDatabases ¶
func CompareDatabases(lhs *db.DatabaseFile, rhs *db.DatabaseFile, onlyLHS bool, fn CompareFn) error
Types ¶
type ChangedFlags ¶
type ChangedFlags uint8
Describe what has changed for an item that exists on both sides.
func (ChangedFlags) FilterFlagsMask ¶
func (f ChangedFlags) FilterFlagsMask() FilterFlags
func (ChangedFlags) HashChanged ¶
func (f ChangedFlags) HashChanged() bool
func (ChangedFlags) ModTimeChanged ¶
func (f ChangedFlags) ModTimeChanged() bool
func (ChangedFlags) ModeChanged ¶
func (f ChangedFlags) ModeChanged() bool
func (ChangedFlags) SizeChanged ¶
func (f ChangedFlags) SizeChanged() bool
type CompareFn ¶
Called by Compare for each difference that was found. Return SkipAll to stop the process.
type Config ¶
type Config struct {
config.CommonConfig
LhsPath string
RhsPath string
IncludeFilters []FilterFlags
ExcludeFilters []FilterFlags
Fn CompareFn
}
Config for the ajfs diff command.
type Diff ¶
type Diff struct {
Type Type // Type of difference
Id path.Id // Identifier of the path info item
Path string // Path of the item
IsDir bool // Is this a directory
Changed ChangedFlags // What was changed
Size uint64 // Size of the item. If the item exists on both sides, then this would be the size of the LHS item
}
Describe a difference between the LHS and RHS databases.
func (Diff) FilterFlagsMask ¶
func (d Diff) FilterFlagsMask() FilterFlags
type DiffStats ¶
type DiffStats struct {
LeftOnly int // Count of left hand side only items
RightOnly int // Count of right hand side only items
Changed int // Count of changed items
NotChanged int // Count of items that exist in both sides and that is unchanged
Files int // Count of files
Dirs int // Count of directories
ModeChanged int // Count of items where the mode has changed
SizeChanged int // Count of items where the size has changed
ModTimeChanged int // Count of items where the last modification time changed
HashChanged int // Count of items where the hash has changed
Fn CompareFn // The compare function to be called
}
DiffStats can be used to get some statistics out of a diff.
type FilterFlags ¶
type FilterFlags uint16
Flags used to decide which items to be included or excluded in a diff.
func ParseFilterFlags ¶
func ParseFilterFlags(input string) (FilterFlags, error)
func ParseFilterFlagsArray ¶
func ParseFilterFlagsArray(input []string) ([]FilterFlags, error)
func (FilterFlags) ChangedFlagsMask ¶
func (f FilterFlags) ChangedFlagsMask() ChangedFlags
func (FilterFlags) String ¶
func (f FilterFlags) String() string
func (FilterFlags) Validate ¶
func (f FilterFlags) Validate() error