Bugfix/snapshot diff - #120
Merged
Merged
Conversation
… snapshot diff state
… deleted/neither cases - Refactor TestDetermineDiffState to use a table-driven approach for clarity and maintainability - Add test cases for deleted files and files missing from both real and snapshot - Extract file setup logic into a helper function for reuse - Simplify DetermineDiffState logic for correctness and readability
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors and improves file existence and diff state logic in the ZFS snapshot codebase, making the code more modular and testable. It introduces a new utility function for file existence checks, renames key methods for clarity, and adds comprehensive unit tests for diff state determination.
Refactoring and logic improvements:
SnapshotFile.Exists()with a new utility functionutil.FileExists, and updated all usages to call this new function for consistency and testability. (internal/data/file_browser_entry.go,internal/util/file.go) [1] [2]CheckIfFileHasChangedtoIsRealFileDifferentin theSnapshotstruct, clarifying its purpose, and updated all references accordingly. (internal/zfs/snapshot.go,internal/data/file_browser_entry.go) [1] [2]DetermineDiffStateto use the new file existence checks and to handle all combinations of real and snapshot file presence, improving correctness and maintainability. (internal/zfs/snapshot.go)Testing:
DetermineDiffState, covering all key scenarios: added, equal, modified, deleted, and neither file exists. (internal/zfs/snapshot_test.go)Utility function:
util.FileExists(path string) boolfor consistent and reusable file existence checks throughout the codebase. (internal/util/file.go)