Add copy deployment type with checksum-based caching#214
Open
JP-Ellis wants to merge 2 commits intoSuperCuber:masterfrom
Open
Add copy deployment type with checksum-based caching#214JP-Ellis wants to merge 2 commits intoSuperCuber:masterfrom
copy deployment type with checksum-based caching#214JP-Ellis wants to merge 2 commits intoSuperCuber:masterfrom
Conversation
Add a `Copy` option to force dotter to copy files to the target. Fixes: SuperCuber#115 Assisted-by: Claude Code:claude-sonnet-4-6 Signed-off-by: JP-Ellis <josh@jpellis.me>
For templates and symlinks, it is easy to see if the target has changed (e.g., symlink is destroyed, or the rendered template differs to the target). This is not as easy to do with copy target; if the source and target differ, it is unclear whether the source was modified and the target is stale, or the target was modified outside of dotter (or both). This changes the caching so that it stores a hash (using `xxhash`) of both source and target. On redeployment, the hashes can be compared and dotter can determine whether it is safe to override the target file. Assisted-by: Claude Code:claude-sonnet-4-6 Signed-off-by: JP-Ellis <josh@jpellis.me>
b911b43 to
81693cb
Compare
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.
Summary
Adds a new
copydeployment type (alongside the existingsymbolic_linkandtemplatetypes). When a file is configured as a copy, dotter copies the source file to the target path rather than creating a symlink or rendering a template.To determine whether the source or destination has changedd, dotter uses checksums (
xxhash) instead of just storing the target path. On redeployment, dotter computes fresh hashes and compares them against the cached values to determine whether it is safe to overwrite the target file. The--forceflag overrides the back-off in all three cases (delete, create, update) for consistency with existing behavior.Background
Issue #115 requests a way to deploy files by copying rather than symlinking. Symlinks work well in most cases but break some tools that do not follow symlinks (certain editors, build systems, and container runtimes). A copy option fills that gap.
The main design challenge is that copy targets are opaque files on disk: unlike symlinks (where the link target is metadata) or templates (where dotter holds the rendered output in a cache file), there is no inherent signal to distinguish a stale copy from a user-edited file. The checksum approach solves this by recording what dotter last wrote to both the source and the target. If the target checksum has drifted from the recorded value, dotter treats the file as externally modified and declines to overwrite it without
--force.The
xxhash-rustcrate (xxh3 variant) is used for hashing. It is non-cryptographic but collision-resistant enough for this use case, and significantly faster than SHA variants for large files.Backward compatibility should be preserved: old cache files that do not have a
copieskey should deserialize cleanly to an empty map via#[serde(default)].Related PRs