Documentation
¶
Index ¶
- Constants
- Variables
- func ConflictFileExists(basePath string) bool
- func GetUnmarkedPath(path string) string
- func IsConflictPath(path string) bool
- func IsLegacyMarkedPath(path string) bool
- func IsMarkedPath(path string) bool
- func IsRejectedPath(path string) bool
- func RejectedFileExists(basePath string) bool
- func RemoveMarker(path string) (string, error)
- func SetMarker(path string, mtype MarkerType) (string, error)
- type BatchCleanups
- type BatchConflict
- type BatchIgnored
- type BatchLocalDelete
- type BatchLocalWrite
- type BatchRemoteDelete
- type BatchRemoteWrite
- type BatchUnchanged
- type ConflictState
- type FileContent
- type FileMetadata
- type FileWatcher
- func (fw *FileWatcher) Events() <-chan notify.EventInfo
- func (fw *FileWatcher) FilterPaths(callback FilterCallback)
- func (fw *FileWatcher) IgnoreOnce(path string)
- func (fw *FileWatcher) IgnoreOnceWithTimeout(path string, timeout time.Duration)
- func (fw *FileWatcher) SetCleanupInterval(interval time.Duration)
- func (fw *FileWatcher) SetDebounceTimeout(timeout time.Duration)
- func (fw *FileWatcher) Start(ctx context.Context) error
- func (fw *FileWatcher) Stop()
- type FilterCallback
- type MarkerType
- type OpType
- type PathStatus
- type ReconcileOperations
- type SyncEngine
- type SyncIgnoreList
- type SyncJournal
- func (s *SyncJournal) Close() error
- func (s *SyncJournal) ContentsChanged(path SyncPath, etag string) (bool, error)
- func (s *SyncJournal) Count() (int, error)
- func (s *SyncJournal) Delete(path SyncPath) error
- func (s *SyncJournal) Destroy() error
- func (s *SyncJournal) Get(path SyncPath) (*FileMetadata, error)
- func (s *SyncJournal) GetPaths() ([]SyncPath, error)
- func (s *SyncJournal) GetState() (map[SyncPath]*FileMetadata, error)
- func (s *SyncJournal) Open() error
- func (s *SyncJournal) Set(state *FileMetadata) error
- type SyncLocalState
- type SyncManager
- type SyncOperation
- type SyncPath
- type SyncPriorityList
- type SyncState
- type SyncStatus
- func (s *SyncStatus) Cleanup(maxAge time.Duration)
- func (s *SyncStatus) Close()
- func (s *SyncStatus) GetAllStatus() map[SyncPath]*PathStatus
- func (s *SyncStatus) GetConflictedFileCount() int
- func (s *SyncStatus) GetConflictedFiles() map[SyncPath]*PathStatus
- func (s *SyncStatus) GetErrorCount(path SyncPath) int
- func (s *SyncStatus) GetRejectedFileCount() int
- func (s *SyncStatus) GetRejectedFiles() map[SyncPath]*PathStatus
- func (s *SyncStatus) GetStatus(path SyncPath) (*PathStatus, bool)
- func (s *SyncStatus) GetSyncingFileCount() int
- func (s *SyncStatus) SetCompleted(path SyncPath)
- func (s *SyncStatus) SetCompletedAndRemove(path SyncPath)
- func (s *SyncStatus) SetConflicted(path SyncPath)
- func (s *SyncStatus) SetError(path SyncPath, err error)
- func (s *SyncStatus) SetProgress(path SyncPath, progress float64)
- func (s *SyncStatus) SetRejected(path SyncPath)
- func (s *SyncStatus) SetSyncing(path SyncPath)
- func (s *SyncStatus) Subscribe() <-chan *SyncStatusEvent
- func (s *SyncStatus) Unsubscribe(ch <-chan *SyncStatusEvent)
- type SyncStatusEvent
Constants ¶
const ( SyncPriority = "Priority" SyncStandard = "Standard" )
const (
DefaultIgnoreTimeout = time.Second
)
Variables ¶
var (
ErrSyncAlreadyRunning = errors.New("sync already running")
)
Functions ¶
func ConflictFileExists ¶ added in v0.7.0
ConflictFileExists checks the filesystem to see if any .conflict file (including rotated versions) exists for the given base path.
func GetUnmarkedPath ¶ added in v0.7.0
GetUnmarkedPath strips all known markers and rotation timestamps from a path string to reveal the original, unmarked path.
func IsConflictPath ¶ added in v0.7.0
IsConflict checks if a path string is specifically marked as a conflict.
func IsLegacyMarkedPath ¶ added in v0.7.0
func IsMarkedPath ¶ added in v0.7.0
IsMarkedPath checks if a given path string contains any known marker, including rotated (timestamped) variants.
func IsRejectedPath ¶ added in v0.7.0
IsRejected checks if a path string is specifically marked as rejected.
func RejectedFileExists ¶ added in v0.7.0
RejectedFileExists checks the filesystem to see if any .rejected file (including rotated versions) exists for the given base path.
func RemoveMarker ¶ added in v0.7.0
RemoveMarker renames a marked file to its original, unmarked name. It returns the original path.
func SetMarker ¶ added in v0.7.0
func SetMarker(path string, mtype MarkerType) (string, error)
SetMarker applies a marker to a file at a given path. If a file with the same marker already exists, it is "rotated" by renaming it with its modification timestamp before the new file is marked. It returns the new path of the marked file.
Types ¶
type BatchCleanups ¶
type BatchCleanups = map[SyncPath]struct{}
BatchCleanups represents a set of paths that require local cleanup (e.g., removing tombstones).
type BatchConflict ¶
type BatchConflict = map[SyncPath]*SyncOperation
BatchConflict represents a collection of sync operations where conflicts were detected.
type BatchIgnored ¶
type BatchIgnored = map[SyncPath]struct{}
BatchIgnored represents a set of paths that were ignored.
type BatchLocalDelete ¶
type BatchLocalDelete = map[SyncPath]*SyncOperation
BatchLocalDelete represents a collection of sync operations for items deleted locally.
type BatchLocalWrite ¶
type BatchLocalWrite = map[SyncPath]*SyncOperation
BatchLocalWrite represents a collection of sync operations for items created or updated locally.
type BatchRemoteDelete ¶
type BatchRemoteDelete = map[SyncPath]*SyncOperation
BatchRemoteDelete represents a collection of sync operations for items deleted remotely.
type BatchRemoteWrite ¶
type BatchRemoteWrite = map[SyncPath]*SyncOperation
BatchRemoteWrite represents a collection of sync operations for items created or updated remotely.
type BatchUnchanged ¶
type BatchUnchanged = map[SyncPath]struct{}
BatchUnchanged represents a set of paths that were compared and found to be unchanged.
type ConflictState ¶ added in v0.7.0
type ConflictState string
ConflictState represents the condition of a file
const ( ConflictStateNone ConflictState = "none" ConflictStateConflicted ConflictState = "conflicted" ConflictStateRejected ConflictState = "rejected" )
type FileContent ¶
type FileContent struct {
FileMetadata
Content []byte
}
func NewFileContent ¶
func NewFileContent(path string) (*FileContent, error)
type FileMetadata ¶
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) FilterPaths ¶ added in v0.7.0
func (fw *FileWatcher) FilterPaths(callback FilterCallback)
FilterPaths sets a callback function to filter out raw events before debouncing The callback should return true if the event should be ignored
func (*FileWatcher) IgnoreOnce ¶ added in v0.7.0
func (fw *FileWatcher) IgnoreOnce(path string)
IgnoreOnce adds a path to be ignored on the next write event with default timeout
func (*FileWatcher) IgnoreOnceWithTimeout ¶ added in v0.7.0
func (fw *FileWatcher) IgnoreOnceWithTimeout(path string, timeout time.Duration)
IgnoreOnceWithTimeout adds a path to be ignored on the next write event with custom timeout
func (*FileWatcher) SetCleanupInterval ¶ added in v0.7.0
func (fw *FileWatcher) SetCleanupInterval(interval time.Duration)
func (*FileWatcher) SetDebounceTimeout ¶ added in v0.7.0
func (fw *FileWatcher) SetDebounceTimeout(timeout time.Duration)
SetDebounceTimeout sets the debounce timeout for events
func (*FileWatcher) Stop ¶
func (fw *FileWatcher) Stop()
type FilterCallback ¶ added in v0.7.0
FilterCallback is a function that returns true if the event should be filtered
type MarkerType ¶ added in v0.7.0
type MarkerType string
MarkerType defines the type of marker to be applied to a file. We use simple dot-suffixes for command-line friendliness (no special chars).
const ( // LegacyRejected marks a file as rejected. LegacyRejected MarkerType = ".syftrejected" // LegacyConflict marks a file as having a conflict. LegacyConflict MarkerType = ".syftconflict" // Rejected marks a file as rejected. Rejected MarkerType = ".rejected" // Conflict marks a file as having a conflict. Conflict MarkerType = ".conflict" )
func GetMarkers ¶ added in v0.7.0
func GetMarkers(path string) []MarkerType
GetMarkers finds all known markers in a given path string.
type PathStatus ¶
type PathStatus struct {
SyncState SyncState
ConflictState ConflictState
Progress float64
Error error
ErrorCount int
LastUpdated time.Time
}
PathStatus represents the complete status of a file
func (*PathStatus) String ¶ added in v0.7.0
func (s *PathStatus) String() string
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, ) (*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) 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 SyncPath, 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 SyncPath) error
Delete removes an entry from the journal by its key (path).
func (*SyncJournal) Destroy ¶
func (s *SyncJournal) Destroy() error
in rare cases when we want to destroy the journal & would want to start afresh
func (*SyncJournal) Get ¶
func (s *SyncJournal) Get(path SyncPath) (*FileMetadata, error)
Get retrieves the metadata for a specific path.
func (*SyncJournal) GetPaths ¶
func (s *SyncJournal) GetPaths() ([]SyncPath, error)
GetPaths retrieves all paths known to the journal.
func (*SyncJournal) GetState ¶
func (s *SyncJournal) GetState() (map[SyncPath]*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[SyncPath]*FileMetadata, error)
type SyncManager ¶
type SyncManager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func (*SyncManager) Stop ¶
func (m *SyncManager) Stop() error
type SyncOperation ¶
type SyncOperation struct {
Type OpType
RelPath SyncPath
Local *FileMetadata
Remote *FileMetadata
LastSynced *FileMetadata
}
type SyncPath ¶ added in v0.7.0
type SyncPath string // common relative path on the client and server
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 SyncState ¶ added in v0.7.0
type SyncState string
SyncState represents the state of a sync operation
type SyncStatus ¶
type SyncStatus struct {
// contains filtered or unexported fields
}
SyncStatus manages the status of file synchronization operations
func NewSyncStatus ¶
func NewSyncStatus() *SyncStatus
func (*SyncStatus) Cleanup ¶ added in v0.7.0
func (s *SyncStatus) Cleanup(maxAge time.Duration)
Cleanup removes completed files older than the specified duration
func (*SyncStatus) Close ¶ added in v0.7.0
func (s *SyncStatus) Close()
func (*SyncStatus) GetAllStatus ¶ added in v0.7.0
func (s *SyncStatus) GetAllStatus() map[SyncPath]*PathStatus
GetAllStatus returns a copy of all file statuses
func (*SyncStatus) GetConflictedFileCount ¶ added in v0.7.0
func (s *SyncStatus) GetConflictedFileCount() int
GetConflictedFileCount returns the number of conflicted files
func (*SyncStatus) GetConflictedFiles ¶ added in v0.7.0
func (s *SyncStatus) GetConflictedFiles() map[SyncPath]*PathStatus
GetConflictedFiles returns a map of all conflicted files
func (*SyncStatus) GetErrorCount ¶ added in v0.7.0
func (s *SyncStatus) GetErrorCount(path SyncPath) int
func (*SyncStatus) GetRejectedFileCount ¶ added in v0.7.0
func (s *SyncStatus) GetRejectedFileCount() int
GetRejectedFileCount returns the number of rejected files
func (*SyncStatus) GetRejectedFiles ¶ added in v0.7.0
func (s *SyncStatus) GetRejectedFiles() map[SyncPath]*PathStatus
GetRejectedFiles returns a map of all rejected files
func (*SyncStatus) GetStatus ¶ added in v0.7.0
func (s *SyncStatus) GetStatus(path SyncPath) (*PathStatus, bool)
GetStatus returns the status of a specific file
func (*SyncStatus) GetSyncingFileCount ¶ added in v0.7.0
func (s *SyncStatus) GetSyncingFileCount() int
GetSyncingFileCount returns the number of files currently syncing
func (*SyncStatus) SetCompleted ¶
func (s *SyncStatus) SetCompleted(path SyncPath)
SetCompleted sets a file to completed state, preserving file state and removing only clean files
func (*SyncStatus) SetCompletedAndRemove ¶ added in v0.7.0
func (s *SyncStatus) SetCompletedAndRemove(path SyncPath)
SetCompletedAndRemove explicitly clears a file to clean state and removes it from tracking
func (*SyncStatus) SetConflicted ¶ added in v0.7.0
func (s *SyncStatus) SetConflicted(path SyncPath)
SetConflicted marks a file as conflicted
func (*SyncStatus) SetError ¶
func (s *SyncStatus) SetError(path SyncPath, err error)
SetError sets a file to error state
func (*SyncStatus) SetProgress ¶
func (s *SyncStatus) SetProgress(path SyncPath, progress float64)
SetProgress updates the progress of a syncing file
func (*SyncStatus) SetRejected ¶ added in v0.7.0
func (s *SyncStatus) SetRejected(path SyncPath)
SetRejected marks a file as rejected
func (*SyncStatus) SetSyncing ¶
func (s *SyncStatus) SetSyncing(path SyncPath)
SetSyncing sets a file to syncing state, preserving conflicted/rejected file state
func (*SyncStatus) Subscribe ¶ added in v0.7.0
func (s *SyncStatus) Subscribe() <-chan *SyncStatusEvent
Subscribe returns a channel for receiving sync status events
func (*SyncStatus) Unsubscribe ¶ added in v0.7.0
func (s *SyncStatus) Unsubscribe(ch <-chan *SyncStatusEvent)
Unsubscribe removes a subscription channel
type SyncStatusEvent ¶
type SyncStatusEvent struct {
Path SyncPath
Status *PathStatus
}
SyncStatusEvent represents a status change event for broadcasting
Source Files
¶
- file_content.go
- file_metadata.go
- file_watcher.go
- sync_engine.go
- sync_engine_conflict.go
- sync_engine_delete.go
- sync_engine_download.go
- sync_engine_priority_download.go
- sync_engine_priority_error.go
- sync_engine_priority_http_download.go
- sync_engine_priority_upload.go
- sync_engine_types.go
- sync_engine_upload.go
- sync_ignore.go
- sync_journal.go
- sync_local_state.go
- sync_manager.go
- sync_marker.go
- sync_op.go
- sync_priority.go
- sync_status.go
- sync_utils.go