Documentation
¶
Index ¶
- type FileChange
- type FileSnapshot
- type FileTracker
- type SnapshotManager
- func (sm *SnapshotManager) Cleanup() error
- func (sm *SnapshotManager) ComputeDiff() ([]FileChange, error)
- func (sm *SnapshotManager) GetChanges() []FileChange
- func (sm *SnapshotManager) Revert(filePath string) error
- func (sm *SnapshotManager) RevertLast() (string, error)
- func (sm *SnapshotManager) Snapshot(filePath string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileChange ¶
FileChange represents the diff stats for a single file.
type FileSnapshot ¶
type FileSnapshot struct {
OriginalPath string
BackupPath string // empty string if file didn't exist (null sentinel)
Version int
Timestamp time.Time
}
FileSnapshot represents a backup of a file before modification.
type FileTracker ¶
type FileTracker struct {
// contains filtered or unexported fields
}
FileTracker tracks file modification times to detect stale reads. When a file is read, its mtime is recorded. Before writing, the caller can check whether the file was modified externally since the last read.
func (*FileTracker) CheckStale ¶
func (ft *FileTracker) CheckStale(path string) error
CheckStale compares the file's current mtime against the stored mtime. Returns an error if the file was modified externally since the last read. Returns nil if the file has never been tracked (first write is allowed).
func (*FileTracker) ClearStale ¶
func (ft *FileTracker) ClearStale(path string)
ClearStale removes tracking for the given path (e.g. after a successful re-read).
func (*FileTracker) RecordRead ¶
func (ft *FileTracker) RecordRead(path string) error
RecordRead stats the file at path and stores its current mtime.
type SnapshotManager ¶
type SnapshotManager struct {
// contains filtered or unexported fields
}
SnapshotManager handles file backups for undo/revert support.
func NewSnapshotManager ¶
func NewSnapshotManager(sessionID string) *SnapshotManager
NewSnapshotManager creates a SnapshotManager for the given session. Backups are stored under ~/.celeste/checkpoints/<sessionID>/.
func (*SnapshotManager) Cleanup ¶
func (sm *SnapshotManager) Cleanup() error
Cleanup removes the entire checkpoint directory for this session.
func (*SnapshotManager) ComputeDiff ¶
func (sm *SnapshotManager) ComputeDiff() ([]FileChange, error)
ComputeDiff compares each snapshot's backup against the current file to compute line-level diff stats.
func (*SnapshotManager) GetChanges ¶
func (sm *SnapshotManager) GetChanges() []FileChange
GetChanges returns a FileChange summary for each file that has been snapshotted.
func (*SnapshotManager) Revert ¶
func (sm *SnapshotManager) Revert(filePath string) error
Revert restores the most recent backup for the given file path.
func (*SnapshotManager) RevertLast ¶
func (sm *SnapshotManager) RevertLast() (string, error)
RevertLast reverts the most recent snapshot regardless of path. Returns the path that was reverted.
func (*SnapshotManager) Snapshot ¶
func (sm *SnapshotManager) Snapshot(filePath string) error
Snapshot creates a backup of the file at filePath before it is modified. If the file does not exist, a sentinel snapshot is recorded (BackupPath = ""). Uses two-phase mtime checking to detect concurrent modifications during backup.