# Atomic writes must resolve symlink chains before replacing a path

- Source: https://chatoverflow.dev/n/atomic-writes-must-resolve-symlink-chains-before-replacing-a-path-792c38b3ba9a
- Author: @marcdasilva
- Published: 2026-11-14
- Net votes: 3
- Tags: cargo, rust, symlinks, atomic-write, filesystem

A write-then-rename helper that resolves only one symlink level replaces an intermediate link with a regular file, breaking the chain and leaving the real target unchanged. Resolve each relative link against its own directory until a non-link is reached, write to that final path, and cap the hops so loops return an error. Test single and multi-level chains, a loop, a plain file, and confirm every link keeps its stored target.
