sync

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2025 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSyncAlreadyRunning = errors.New("sync already running")
)

Functions

This section is empty.

Types

type BatchCleanups

type BatchCleanups = map[string]struct{}

BatchCleanups represents a set of paths that require local cleanup (e.g., removing tombstones).

type BatchConflict

type BatchConflict = map[string]*SyncOperation

BatchConflict represents a collection of sync operations where conflicts were detected.

type BatchIgnored

type BatchIgnored = map[string]struct{}

BatchIgnored represents a set of paths that were ignored.

type BatchLocalDelete

type BatchLocalDelete = map[string]*SyncOperation

BatchLocalDelete represents a collection of sync operations for items deleted locally.

type BatchLocalWrite

type BatchLocalWrite = map[string]*SyncOperation

BatchLocalWrite represents a collection of sync operations for items created or updated locally.

type BatchRemoteDelete

type BatchRemoteDelete = map[string]*SyncOperation

BatchRemoteDelete represents a collection of sync operations for items deleted remotely.

type BatchRemoteWrite

type BatchRemoteWrite = map[string]*SyncOperation

BatchRemoteWrite represents a collection of sync operations for items created or updated remotely.

type BatchUnchanged

type BatchUnchanged = map[string]struct{}

BatchUnchanged represents a set of paths that were compared and found to be unchanged.

type FileContent

type FileContent struct {
	FileMetadata
	Content []byte
}

func NewFileContent

func NewFileContent(path string) (*FileContent, error)

type FileMetadata

type FileMetadata struct {
	Path         string
	Size         int64
	ETag         string
	Version      string
	LastModified time.Time
}

type FileWatcher

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

func NewFileWatcher

func NewFileWatcher(watchDir string) *FileWatcher

func (*FileWatcher) Events

func (fw *FileWatcher) Events() <-chan notify.EventInfo

func (*FileWatcher) Start

func (fw *FileWatcher) Start(ctx context.Context) error

func (*FileWatcher) Stop

func (fw *FileWatcher) Stop()

type OpType

type OpType uint8
const (
	OpWriteRemote OpType = iota
	OpWriteLocal
	OpDeleteRemote
	OpDeleteLocal
	OpRenameRemote
	OpRenameLocal
	OpConflict
	OpError
)

func (OpType) String

func (op OpType) String() string

type PathStatus

type PathStatus struct{}

type ReconcileOperations

type ReconcileOperations struct {
	LocalWrites    BatchLocalWrite
	RemoteWrites   BatchRemoteWrite
	LocalDeletes   BatchLocalDelete
	RemoteDeletes  BatchRemoteDelete
	Conflicts      BatchConflict
	UnchangedPaths BatchUnchanged
	Cleanups       BatchCleanups
	Ignored        BatchIgnored
	Total          int
}

ReconcileOperations aggregates the results of a sync reconciliation process, categorizing operations based on their type and origin.

func NewReconcileOperations

func NewReconcileOperations() *ReconcileOperations

NewReconcileOperations initializes and returns an empty ReconcileOperations struct.

func (*ReconcileOperations) HasChanges

func (r *ReconcileOperations) HasChanges() bool

HasChanges returns true if there are any pending write, delete, conflict, or cleanup operations resulting from the reconciliation.

type SyncEngine

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

func NewSyncEngine

func NewSyncEngine(
	workspace *workspace.Workspace,
	sdk *syftsdk.SyftSDK,
	ignore *SyncIgnoreList,
	priority *SyncPriorityList,
	watcher *FileWatcher,
) (*SyncEngine, error)

func (*SyncEngine) RunSync

func (se *SyncEngine) RunSync(ctx context.Context) error

RunSync performs a full sync of the local and remote states

func (*SyncEngine) Start

func (se *SyncEngine) Start(ctx context.Context) error

func (*SyncEngine) Stop

func (se *SyncEngine) Stop() error

type SyncIgnoreList

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

func NewSyncIgnoreList

func NewSyncIgnoreList(baseDir string) *SyncIgnoreList

func (*SyncIgnoreList) Load

func (s *SyncIgnoreList) Load()

func (*SyncIgnoreList) ShouldIgnore

func (s *SyncIgnoreList) ShouldIgnore(path string) bool

type SyncJournal

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

SyncJournal manages the persistent state of synced files using SQLite.

func NewSyncJournal

func NewSyncJournal(dbPath string) (*SyncJournal, error)

NewSyncJournal creates or opens a SyncJournal backed by an SQLite database.

func (*SyncJournal) Close

func (s *SyncJournal) Close() error

Close closes the underlying database connection.

func (*SyncJournal) ContentsChanged

func (s *SyncJournal) ContentsChanged(path string, etag string) (bool, error)

func (*SyncJournal) Count

func (s *SyncJournal) Count() (int, error)

Count returns the number of entries in the journal.

func (*SyncJournal) Delete

func (s *SyncJournal) Delete(path string) error

Delete removes an entry from the journal by its key (path).

func (*SyncJournal) Destroy

func (s *SyncJournal) Destroy() error

func (*SyncJournal) Get

func (s *SyncJournal) Get(path string) (*FileMetadata, error)

Get retrieves the metadata for a specific path.

func (*SyncJournal) GetPaths

func (s *SyncJournal) GetPaths() ([]string, error)

GetPaths retrieves all paths known to the journal.

func (*SyncJournal) GetState

func (s *SyncJournal) GetState() (map[string]*FileMetadata, error)

GetState retrieves the entire state map from the journal.

func (*SyncJournal) Open

func (s *SyncJournal) Open() error

Open the sync journal and the underlying database

func (*SyncJournal) Set

func (s *SyncJournal) Set(state *FileMetadata) error

Set inserts or updates the metadata for a specific path using named parameters.

type SyncLocalState

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

func NewSyncLocalState

func NewSyncLocalState(rootDir string) *SyncLocalState

func (*SyncLocalState) Scan

func (s *SyncLocalState) Scan() (map[string]*FileMetadata, error)

type SyncManager

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

func NewManager

func NewManager(workspace *workspace.Workspace, sdk *syftsdk.SyftSDK) (*SyncManager, error)

func (*SyncManager) Start

func (m *SyncManager) Start(ctx context.Context) error

func (*SyncManager) Stop

func (m *SyncManager) Stop() error

type SyncOperation

type SyncOperation struct {
	Op         OpType
	RelPath    string // Datasite relative path
	Local      *FileMetadata
	Remote     *FileMetadata
	LastSynced *FileMetadata
}

type SyncPriorityList

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

func NewSyncPriorityList

func NewSyncPriorityList(baseDir string) *SyncPriorityList

func (*SyncPriorityList) ShouldPrioritize

func (s *SyncPriorityList) ShouldPrioritize(path string) bool

type SyncStatus

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

func NewSyncStatus

func NewSyncStatus() *SyncStatus

func (*SyncStatus) Count

func (s *SyncStatus) Count() int

func (*SyncStatus) IsSyncing

func (s *SyncStatus) IsSyncing(path string) bool

func (*SyncStatus) SetCompleted

func (s *SyncStatus) SetCompleted(path string, src string)

func (*SyncStatus) SetError

func (s *SyncStatus) SetError(path string, src string)

func (*SyncStatus) SetProgress

func (s *SyncStatus) SetProgress(path string, progress float64)

func (*SyncStatus) SetSyncing

func (s *SyncStatus) SetSyncing(path string, src string)

type SyncStatusEvent

type SyncStatusEvent struct{}

Jump to

Keyboard shortcuts

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