trackrenames

package
v1.76.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package trackrenames matches source and destination objects for server-side renames.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckCapabilities

func CheckCapabilities(ctx context.Context, fsrc, fdst fs.Fs, strategy Strategy) (hashType hash.Type, modifyWindow time.Duration, unsupported []string)

CheckCapabilities returns the filesystem capabilities and any reasons strategy cannot be used.

func CountGuaranteedMatches

func CountGuaranteedMatches(strategy Strategy, modifyWindow time.Duration, sources, destinations []Candidate) int

CountGuaranteedMatches returns a lower bound on matches independent of matching order.

Types

type Candidate

type Candidate struct {
	Remote  string    // Remote is the object path.
	Size    int64     // Size is the object size in bytes.
	ModTime time.Time // ModTime is the object modification time.
	Hash    string    // Hash is the value of the common hash type.
}

Candidate contains the object attributes used to match a tracked rename.

type Matcher

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

Matcher stores destination objects and consumes them when a source object matches.

func NewMatcher

func NewMatcher(ctx context.Context, strategy Strategy, hashType hash.Type, modifyWindow time.Duration) *Matcher

NewMatcher constructs an empty rename matcher.

func (*Matcher) Add

func (m *Matcher) Add(obj fs.Object) bool

Add stores a destination object and reports whether it produced a usable identifier.

func (*Matcher) Match

func (m *Matcher) Match(src fs.Object) (dst fs.Object)

Match consumes and returns the first destination object matching src.

type Strategy

type Strategy byte

Strategy identifies the object attributes used to match renames.

const (
	// StrategyHash includes the configured hash in the rename identifier.
	StrategyHash Strategy = 1 << iota
	// StrategyModtime requires matching modification times within the modify window.
	StrategyModtime
	// StrategyLeaf includes the leaf name in the rename identifier.
	StrategyLeaf
)

func ParseStrategy

func ParseStrategy(strategies string) (strategy Strategy, err error)

ParseStrategy parses a comma-separated track-renames strategy.

func (Strategy) UsesHash

func (strategy Strategy) UsesHash() bool

UsesHash reports whether the strategy compares hashes.

func (Strategy) UsesLeaf

func (strategy Strategy) UsesLeaf() bool

UsesLeaf reports whether the strategy compares leaf names.

func (Strategy) UsesModtime

func (strategy Strategy) UsesModtime() bool

UsesModtime reports whether the strategy compares modification times.

Jump to

Keyboard shortcuts

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