feat: add ignore-empty-snapshot backup option#191
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
Adds an opt-in ignore-empty-snapshot backup option to skip snapshot creation when the resulting tree is unchanged from the previous snapshot for the same source lineage, and wires it through CLI, profiles, docs, and shell completions (Closes #190).
Changes:
- Engine: add
WithIgnoreEmptySnapshotand anEmptySnapshotIgnoredrun result flag, and short-circuit snapshot persistence when roots match. - CLI/profiles: expose
-ignore-empty-snapshotinbackupandprofile new, profile YAML (ignore_empty), usage output, profile display, and shell completion. - Tests/docs: add engine + CLI tests for the ignored-empty-snapshot path and document behavior (including change-token implications for changes-based sources).
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/engine/profiles.go | Adds IgnoreEmpty to backup profile YAML schema. |
| internal/engine/backup.go | Implements ignore-empty-snapshot option + result flag. |
| internal/engine/backup_test.go | Adds engine test covering ignore-empty-snapshot behavior and index stability. |
| docs/user-guide.md | Documents -ignore-empty-snapshot and its implications for changes-based sources. |
| cmd/cloudstic/usage.go | Adds flag to usage output. |
| cmd/cloudstic/config_tables.go | Displays profile setting in profile show. |
| cmd/cloudstic/completion.go | Adds flag to bash/zsh/fish completions for backup and profile new. |
| cmd/cloudstic/completion_test.go | Verifies completion output includes the new flag. |
| cmd/cloudstic/cmd_profile.go | Adds flag to profile new and persists to profiles.yaml. |
| cmd/cloudstic/cmd_backup.go | Adds CLI flag, merges profile setting, passes option to engine, updates summary output. |
| cmd/cloudstic/cmd_backup_test.go | Adds tests for building opts and summary output when snapshot is ignored. |
| cmd/cloudstic/cmd_backup_profile_test.go | Adds profile merge test coverage for ignore-empty setting. |
| client.go | Re-exports WithIgnoreEmptySnapshot from engine. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if bm.cfg.ignoreEmptySnapshot && prevSnap != nil && newRoot == oldRoot { | ||
| r := bm.buildResult() | ||
| r.Root = newRoot | ||
| r.EmptySnapshotIgnored = true | ||
| return r, nil | ||
| } |
There was a problem hiding this comment.
The ignore-empty-snapshot fast-path runs after flushPendingMetas, PreloadKeys, and upload. On an unchanged backup pending is typically empty and newRoot == oldRoot, so PreloadKeys will still list all chunk/, content/, and node/ keys even though no upload is needed. Consider moving the ignore-empty check earlier (right after scanSource, gated on prevSnap != nil && len(pending)==0 && newRoot==oldRoot and optionally len(bm.pendingMetas)==0) so unchanged runs can return without the expensive key preloading step.
Summary
Testing
Closes #190