Tuckr icon indicating copy to clipboard operation
Tuckr copied to clipboard

Feature: allow shallow symlinks

Open utkarshgupta137 opened this issue 1 year ago • 5 comments

GNU stow can do shallow symlinking i.e. if the directory is already present, it will symlink the files inside it, leaving the directory untouched. This allows other files to be in the same directory as config files. prezto for example supports using ZDOTDIR, but it needs the .zprezto folder to be in the same folder as my rc files. Also, lazygit creates a state.yml file which I don't want in my dotfiles repo.

utkarshgupta137 avatar Apr 04 '23 20:04 utkarshgupta137

I'm confused by the explanation, did you mean like when there's already files in a directory stow instead of stow symlinking that directory it simply symlinks the files inside the directory there?

RaphGL avatar Apr 05 '23 13:04 RaphGL

I'm confused by the explanation, did you mean like when there's already files in a directory stow instead of stow symlinking that directory it simply symlinks the files inside the directory there?

Yes.

utkarshgupta137 avatar Apr 05 '23 13:04 utkarshgupta137

Alright, this makes sense. It's probably easy to implement too. I don't know why it didn't cross my mind while writing it the first time. I'll see what I can do.

RaphGL avatar Apr 05 '23 14:04 RaphGL

I decided to tackle this today and honestly it's turned out to be harder to implement then I thought. Mostly because of the assumptions I initially had on how validation should work and the data structures I chose. I've been tweaking a bit and managed to implement shallow symlinks but it completely broke the validation.

So I'm going to try and move from using HashSets to HashMaps in an attempt to make recognizing that a parent has been symlinked. The issue is that the original implementation simplified things by making so one group was one symlink, but with shallow symlinks a group can be a bunch of symlinks and it might not even own the group folder. So I need a way to be able to check every file, but most files won't be actual symlinks so I need to detect that it's parent has been symlinked.

If I manage to fix symlink validation I'll push the changes to main, if it proves to be too annoying to implement I might end up postponing it for when I find a solution

RaphGL avatar Apr 06 '23 23:04 RaphGL

Marked this as "help wanted" as I've been struggling to implement this correctly for the past 2 months. I'm not sure how to approach this problem yet, I've thought about implementing some sort of BFS or something to be able to detect files that share at least one parent but I haven't gotten around to try that yet.

If anyone is willing to give it a shot and wants help with navigating the code base, mark me and I'll help out.

RaphGL avatar Jun 03 '23 18:06 RaphGL

This issue is now fixed. As far as I'm aware, shallow symlinking is working properly. Bare in mind that this is likely a breaking change. So I recommend doing the following:

  • Before upgrade remove all your dotfiles
$ tuckr rm \*
  • After updating you can resymlink again
$ tuckr add \*

Note: adding shallow symlinks required changing things a little bit so conflict detection isn't working properly for now cause of the difference in how symlinks are being done now (will be fixing it very soon). you'll just see your groups on "not symlinked" for even if they're in conflict, forcing or adopting groups still works as intended.

RaphGL avatar Jul 06 '24 23:07 RaphGL