source

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrResumeTargetIDEmpty = errors.New("resume target id is empty")
	ErrResumeDirEmpty      = errors.New("resume directory is empty")
	ErrResumeDirNotDir     = errors.New("resume directory is not a directory")
)

Functions

func Dedupe

func Dedupe[T comparable](values []T) []T

Dedupe returns a stable deduplicated copy of values.

func DedupeAndSort

func DedupeAndSort(values []string) []string

DedupeAndSort returns a sorted, deduplicated copy of values, skipping empty strings.

func FileNeedsSync

func FileNeedsSync(srcInfo os.FileInfo, dstPath string) bool

FileNeedsSync returns true if the destination is missing, different, or older.

func FileNeedsSyncInfo

func FileNeedsSyncInfo(srcInfo, dstInfo os.FileInfo) bool

FileNeedsSyncInfo compares pre-obtained source and destination file info. Use this when both infos are already available to avoid redundant stat calls.

func FindInsertPosition

func FindInsertPosition[T any](items []T, anchor time.Time, timestamp func(T) time.Time) int

FindInsertPosition returns the index after the latest timestamp not after anchor.

func FirstNonZeroTime

func FirstNonZeroTime[T any](items []T, timestamp func(T) time.Time) time.Time

FirstNonZeroTime returns the first non-zero time from items, or zero if none found.

func InsertAt

func InsertAt[T any](items []T, index int, item T) []T

InsertAt inserts a single item at the given index.

func InsertSliceAt

func InsertSliceAt[T any](items []T, index int, inserted []T) []T

InsertSliceAt inserts multiple items at the given index.

func ProviderRawDir

func ProviderRawDir(archiveDir string, provider conv.Provider) string

ProviderRawDir returns the provider-specific raw archive path.

func SortedKeys

func SortedKeys(values map[string]struct{}) []string

SortedKeys returns the keys of a set as a sorted slice.

func StatDir

func StatDir(path string) (bool, error)

StatDir returns whether path exists and is a directory.

func ValidateResumeTarget

func ValidateResumeTarget(target conv.ResumeTarget) error

ValidateResumeTarget applies the shared strict resume policy.

Types

type Analysis

type Analysis struct {
	UnitsTotal       int
	FilesInspected   int
	Conversations    int
	NewConversations int
	ToUpdate         int
	UpToDate         int
	SyncCandidates   []string
}

Analysis describes provider-local import state before syncing raw files.

type Backend

type Backend interface {
	Provider() conv.Provider
	Scan(ctx context.Context, rawDir string) ([]conv.Conversation, error)
	Load(ctx context.Context, conversation conv.Conversation) (conv.Session, error)
	Analyze(ctx context.Context, sourceDir, rawDir string, onProgress func(Progress)) (Analysis, error)
	SyncCandidates(ctx context.Context, sourceDir, rawDir string) ([]SyncCandidate, error)
	ResumeCommand(target conv.ResumeTarget) (*exec.Cmd, error)
}

Backend is the generic provider contract used by archive, canonical, and app.

type IncrementalLookup

type IncrementalLookup interface {
	ConversationByFilePath(ctx context.Context, provider conv.Provider, filePath string) (conv.Conversation, bool, error)
	ConversationBySessionID(ctx context.Context, provider conv.Provider, sessionID string) (conv.Conversation, bool, error)
	ConversationByCacheKey(ctx context.Context, cacheKey string) (conv.Conversation, bool, error)
}

IncrementalLookup provides canonical-store conversation lookups for provider-local targeted rebuild resolution.

type IncrementalResolution

type IncrementalResolution struct {
	Conversations    []conv.Conversation
	ReplaceCacheKeys []string
}

IncrementalResolution describes the exact conversations that should be replaced during a targeted canonical rebuild.

type IncrementalResolver

type IncrementalResolver interface {
	ResolveIncremental(
		ctx context.Context,
		rawDir string,
		changedRawPaths []string,
		lookup IncrementalLookup,
	) (IncrementalResolution, error)
}

IncrementalResolver is an optional provider hook for targeted canonical rebuilds driven by changed raw paths.

type Progress

type Progress struct {
	Provider         conv.Provider
	UnitsCompleted   int
	UnitsTotal       int
	FilesInspected   int
	Conversations    int
	NewConversations int
	ToUpdate         int
	CurrentUnit      string
	Err              error
}

Progress reports provider-local analysis progress using provider-neutral terms.

type SyncCandidate

type SyncCandidate struct {
	SourcePath string
	DestPath   string
	DestExists bool
}

SyncCandidate is a backend-owned raw-file sync plan item.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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