diff

package
v0.0.1-beta6 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package diff provides the functionality for ajfs diff command.

Index

Constants

View Source
const (
	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
)

Variables

View Source
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, onlyLHS bool, 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

func Run

func Run(cfg Config) error

Process the ajfs diff command.

Types

type ChangedFlags

type ChangedFlags uint8

Describe what has changed for an item that exists on both sides.

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

type CompareFn func(d Diff) error

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

	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) String

func (d *Diff) String() string

Stringer implementation.

type Type

type Type int

Describe the type of difference.

const (
	TypeNothing        = 0        // Nothing changed
	TypeLeftOnly  Type = 1 + iota // Only on the LHS (same as having been removed from the RHS)
	TypeRightOnly                 // Only on the RHS (same as having been added in the RHS)
	TypeChanged                   // Some of the file's meta data or the hash have been changed
)

Jump to

Keyboard shortcuts

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