core

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BackupDirName = ".sync-backup"
	MaxBackups    = 5
	BackupPrefix  = "backup_"
)
View Source
const (
	HistoryDirName  = ".sync-history"
	HistoryFileName = "history.json"
	MaxHistorySize  = 50
)
View Source
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 NewArchive

func NewArchive(path string) *Archive

NewArchive creates a new Archive instance

func (*Archive) Create

func (a *Archive) Create(manifest *types.Manifest, workDir string) error

Create creates a new archive with the given manifest and files

func (*Archive) ExtractAll

func (a *Archive) ExtractAll(targetDir string) error

ExtractAll extracts all files to the target directory

func (*Archive) ExtractFile

func (a *Archive) ExtractFile(archivePath string) ([]byte, error)

ExtractFile extracts a single file from the archive

func (*Archive) GetFileContent

func (a *Archive) GetFileContent(path string) ([]byte, error)

GetFileContent reads a file from the archive

func (*Archive) ListEntries

func (a *Archive) ListEntries() ([]string, error)

ListEntries returns all entries in the archive

func (*Archive) ReadManifest

func (a *Archive) ReadManifest() (*types.Manifest, error)

ReadManifest reads the manifest from an 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 NewGit

func NewGit(workDir string) *Git

NewGit creates a new Git instance

func (*Git) GetAllChanges

func (g *Git) GetAllChanges() ([]types.FileOperation, error)

GetAllChanges returns all changes (staged + unstaged + untracked)

func (*Git) GetAllFiles

func (g *Git) GetAllFiles() ([]string, error)

GetAllFiles returns all tracked and untracked files

func (*Git) GetSourceInfo

func (g *Git) GetSourceInfo() (*types.SourceInfo, error)

GetSourceInfo returns repository information

func (*Git) GetStatus

func (g *Git) GetStatus() (*types.GitStatus, error)

GetStatus returns the git status with all changes

func (*Git) IsFileModified

func (g *Git) IsFileModified(path string) bool

IsFileModified checks if a file has local modifications

func (*Git) IsRepo

func (g *Git) IsRepo() bool

IsRepo checks if the directory is a git repository

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) Clear

func (h *HistoryManager) Clear() error

Clear clears all history

func (*HistoryManager) GetEntries

func (h *HistoryManager) GetEntries() ([]types.HistoryEntry, error)

GetEntries returns all history entries

func (*HistoryManager) Load

func (h *HistoryManager) Load() (*types.History, error)

Load loads the history from file

func (*HistoryManager) Save

func (h *HistoryManager) Save(history *types.History) error

Save saves the history to file

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

Jump to

Keyboard shortcuts

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