Skip to content

Add copy deployment type with checksum-based caching#214

Open
JP-Ellis wants to merge 2 commits intoSuperCuber:masterfrom
JP-Ellis:feat/add-copy-deployment
Open

Add copy deployment type with checksum-based caching#214
JP-Ellis wants to merge 2 commits intoSuperCuber:masterfrom
JP-Ellis:feat/add-copy-deployment

Conversation

@JP-Ellis
Copy link
Copy Markdown
Contributor

Summary

Adds a new copy deployment type (alongside the existing symbolic_link and template types). 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 --force flag 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-rust crate (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 copies key should deserialize cleanly to an empty map via #[serde(default)].

Related PRs

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>
@JP-Ellis JP-Ellis force-pushed the feat/add-copy-deployment branch from b911b43 to 81693cb Compare April 22, 2026 03:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Always copy

1 participant