Skip to content

Conversation

@slowsage
Copy link

@slowsage slowsage commented Sep 26, 2025

What does this PR do?

This change reduces unnecessary filesystem operations and preserves user‑created symlinks when no alternate is tracked. Stale links are still removed (#236). Added two tests. #65 still passes.

What issues does this PR fix or reference?

#236

Previous Behavior

#236

ln -s /nix/store/abc123/bashrc ~/.bashrc              # User's symlink
echo "content" > ~/.config/yadm/alt/.bashrc##os.Darwin  # (assume not on Darwin)
yadm add ~/.config/yadm/alt/.bashrc##os.Darwin         # Track it
yadm alt # Result: ~/.bashrc REMOVED (even with score=0)

Touch only when necessary:

yadm alt;yadm alt  # (mtime changes on second alt)

New Behavior

#236

ln -s /nix/store/abc123/bashrc ~/.bashrc              # User's symlink
echo "content" > ~/.config/yadm/alt/.bashrc##os.Darwin  # (assume not on Darwin))
yadm add ~/.config/yadm/alt/.bashrc##os.Darwin         # Track it
yadm alt # Result: ~/.bashrc unchanged (score=0 for Darwin, skipped)

Touch only when necessary

yadm alt;yadm alt # mtime unchanged

Have tests been written for this change?

Yes

Have these commits been signed with GnuPG?

Yes


Please review yadm's Contributing Guide for best practices.

@slowsage slowsage force-pushed the softalt branch 5 times, most recently from 863a61e to b3ac902 Compare October 3, 2025 17:52
Tests:
yadm-dev#65 (test_stale_link_removal) still passes.
yadm-dev#236 (test_alt_preserves_user_symlink_until_alt_tracked)
lazy touch (test_alt_skips_correct_symlink_without_touching)
@slowsage slowsage marked this pull request as ready for review October 3, 2025 19:51
@slowsage slowsage changed the title Optimize alt linking to avoid redundant operations Optimize alt linking to avoid redundant operations (fixes #236) Oct 3, 2025
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.

1 participant