sync

package
v0.1.2-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package sync handles building and executing file sync plans.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decision

type Decision int

Decision represents a user-selectable sync action for a single file.

const (
	DecisionNone Decision = iota
	DecisionUpload
	DecisionDownload
	DecisionDeleteLocal
	DecisionDeleteRemote
)

func AutoDecision

func AutoDecision(s *diff.Session) Decision

AutoDecision returns the most sensible default decision for a diff session.

A 2-second threshold tolerates FAT32 time resolution and minor clock drift.

func NextDecision

func NextDecision(cur Decision, s *diff.Session) Decision

NextDecision cycles through the valid decisions for a session state.

Both sides exist : None → Upload → Download → None
Local only       : None → Upload → DeleteLocal → None
Remote only      : None → Download → DeleteRemote → None

type ItemProgress

type ItemProgress struct {
	Item       SyncItem
	Status     ItemStatus
	BytesDone  int64
	BytesTotal int64
	Err        error
}

ItemProgress holds the current transfer state for one SyncItem.

type ItemStatus

type ItemStatus int

ItemStatus tracks the state of a single SyncItem during execution.

const (
	ItemPending ItemStatus = iota
	ItemInFlight
	ItemDone
	ItemFailed
)

type Plan

type Plan struct {
	Host  config.Host
	Items []SyncItem
}

Plan collects all items to be synced for a given host.

type Progress

type Progress struct {
	Items      []ItemProgress
	TotalBytes int64
	SentBytes  int64
}

Progress holds the overall sync execution state.

type SyncDirection

type SyncDirection int

SyncDirection specifies whether to push local→remote or pull remote→local.

const (
	DirectionUpload   SyncDirection = iota // local → remote
	DirectionDownload                      // remote → local
)

type SyncItem

type SyncItem struct {
	LocalPath  string
	RemotePath string
	Direction  SyncDirection
}

SyncItem is a single file to transfer.

Jump to

Keyboard shortcuts

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