Documentation
¶
Index ¶
- Constants
- func CalculateStats(operations []types.FileOperation) types.ExportStats
- func FilterConflicting(operations []types.FileOperation, conflicts []types.Conflict) []types.FileOperation
- type Archive
- func (a *Archive) Create(manifest *types.Manifest, workDir string) error
- func (a *Archive) ExtractAll(targetDir string) error
- func (a *Archive) ExtractFile(archivePath string) ([]byte, error)
- func (a *Archive) GetFileContent(path string) ([]byte, error)
- func (a *Archive) ListEntries() ([]string, error)
- func (a *Archive) ReadManifest() (*types.Manifest, error)
- type BackupManager
- type DiffChecker
- type Git
- type HistoryManager
- func (h *HistoryManager) AddEntry(entryType types.HistoryEntryType, archive string, stats types.ExportStats, ...) error
- func (h *HistoryManager) Clear() error
- func (h *HistoryManager) GetEntries() ([]types.HistoryEntry, error)
- func (h *HistoryManager) Load() (*types.History, error)
- func (h *HistoryManager) Save(history *types.History) error
- type ManifestBuilder
- func (b *ManifestBuilder) AddOperation(op types.FileOperation) bool
- func (b *ManifestBuilder) AddOperations(ops []types.FileOperation) []types.FileOperation
- func (b *ManifestBuilder) Build() *types.Manifest
- func (b *ManifestBuilder) SetMessage(message string) *ManifestBuilder
- func (b *ManifestBuilder) SetMode(mode types.ExportMode) *ManifestBuilder
- func (b *ManifestBuilder) SetSource(source *types.SourceInfo) *ManifestBuilder
Constants ¶
const ( BackupDirName = ".sync-backup" MaxBackups = 5 BackupPrefix = "backup_" )
const ( HistoryDirName = ".sync-history" HistoryFileName = "history.json" MaxHistorySize = 50 )
const ManifestVersion = "1.0"
Variables ¶
This section is empty.
Functions ¶
func CalculateStats ¶
func CalculateStats(operations []types.FileOperation) types.ExportStats
CalculateStats calculates statistics from operations
func FilterConflicting ¶
func FilterConflicting(operations []types.FileOperation, conflicts []types.Conflict) []types.FileOperation
FilterConflicting removes conflicting operations from the list
Types ¶
type Archive ¶
type Archive struct {
// contains filtered or unexported fields
}
Archive handles ZIP archive operations
func (*Archive) ExtractAll ¶
ExtractAll extracts all files to the target directory
func (*Archive) ExtractFile ¶
ExtractFile extracts a single file from the archive
func (*Archive) GetFileContent ¶
GetFileContent reads a file from the archive
func (*Archive) ListEntries ¶
ListEntries returns all entries in the archive
type BackupManager ¶
type BackupManager struct {
// contains filtered or unexported fields
}
BackupManager manages backups
func NewBackupManager ¶
func NewBackupManager(workDir string) *BackupManager
NewBackupManager creates a new BackupManager
func (*BackupManager) CreateBackup ¶
func (b *BackupManager) CreateBackup(operations []types.FileOperation) (string, error)
CreateBackup creates a backup of files that will be modified
func (*BackupManager) GetBackupDir ¶
func (b *BackupManager) GetBackupDir() string
GetBackupDir returns the backup directory path
func (*BackupManager) ListBackups ¶
func (b *BackupManager) ListBackups() ([]string, error)
ListBackups returns a list of available backups
func (*BackupManager) RestoreBackup ¶
func (b *BackupManager) RestoreBackup(backupPath string) error
RestoreBackup restores files from a backup
type DiffChecker ¶
type DiffChecker struct {
// contains filtered or unexported fields
}
DiffChecker checks for conflicts between archive operations and local files
func NewDiffChecker ¶
func NewDiffChecker(workDir string) *DiffChecker
NewDiffChecker creates a new DiffChecker
func (*DiffChecker) CheckConflicts ¶
func (d *DiffChecker) CheckConflicts(operations []types.FileOperation) ([]types.Conflict, error)
CheckConflicts checks for conflicts between operations and local state
func (*DiffChecker) SortOperations ¶
func (d *DiffChecker) SortOperations(operations []types.FileOperation) []types.FileOperation
SortOperations sorts operations in safe application order: 1. Deletes first 2. Renames second 3. Modifies/Adds last
func (*DiffChecker) ValidatePaths ¶
func (d *DiffChecker) ValidatePaths(operations []types.FileOperation) error
ValidatePaths validates paths for security issues
type Git ¶
type Git struct {
// contains filtered or unexported fields
}
Git provides git operations
func (*Git) GetAllChanges ¶
func (g *Git) GetAllChanges() ([]types.FileOperation, error)
GetAllChanges returns all changes (staged + unstaged + untracked)
func (*Git) GetAllFiles ¶
GetAllFiles returns all tracked and untracked files
func (*Git) GetSourceInfo ¶
func (g *Git) GetSourceInfo() (*types.SourceInfo, error)
GetSourceInfo returns repository information
func (*Git) IsFileModified ¶
IsFileModified checks if a file has local modifications
type HistoryManager ¶
type HistoryManager struct {
// contains filtered or unexported fields
}
HistoryManager manages sync history
func NewHistoryManager ¶
func NewHistoryManager(workDir string) *HistoryManager
NewHistoryManager creates a new HistoryManager
func (*HistoryManager) AddEntry ¶
func (h *HistoryManager) AddEntry(entryType types.HistoryEntryType, archive string, stats types.ExportStats, source *types.SourceInfo, message string) error
AddEntry adds a new history entry
func (*HistoryManager) GetEntries ¶
func (h *HistoryManager) GetEntries() ([]types.HistoryEntry, error)
GetEntries returns all history entries
type ManifestBuilder ¶
type ManifestBuilder struct {
// contains filtered or unexported fields
}
ManifestBuilder helps build manifests
func NewManifestBuilder ¶
func NewManifestBuilder(workDir string) *ManifestBuilder
NewManifestBuilder creates a new ManifestBuilder
func (*ManifestBuilder) AddOperation ¶
func (b *ManifestBuilder) AddOperation(op types.FileOperation) bool
AddOperation adds an operation to the manifest. Returns false if the file does not exist on disk (for non-delete operations).
func (*ManifestBuilder) AddOperations ¶
func (b *ManifestBuilder) AddOperations(ops []types.FileOperation) []types.FileOperation
AddOperations adds multiple operations. Returns a slice of operations that were skipped (file not found on disk).
func (*ManifestBuilder) Build ¶
func (b *ManifestBuilder) Build() *types.Manifest
Build builds and returns the manifest with calculated stats
func (*ManifestBuilder) SetMessage ¶
func (b *ManifestBuilder) SetMessage(message string) *ManifestBuilder
SetMessage sets the message
func (*ManifestBuilder) SetMode ¶
func (b *ManifestBuilder) SetMode(mode types.ExportMode) *ManifestBuilder
SetMode sets the export mode
func (*ManifestBuilder) SetSource ¶
func (b *ManifestBuilder) SetSource(source *types.SourceInfo) *ManifestBuilder
SetSource sets the source info