JakobGM / astrality

Astrality - A modular and dynamic configuration file manager
https://astrality.readthedocs.io
MIT License
98 stars 3 forks source link

Support nested symlinks in SymlinkAction #137

Closed KeithScheiwiller closed 5 years ago

KeithScheiwiller commented 5 years ago

I noticed that the SymlinkAction doesn't support nested symlinks, since it skips over any directories in resolve_targets() and it seems python's pathlib glob() will not follow symlinks.

The motivation for supporting this is because I like to have a "shared" directory for an application's dotfiles, then each separate host directory can symlink to the shared directory. As-is, this would not work with astrality. I initially tried to add logic to support "single" symlinks, i.e. where the content dir gets symlinked to target dir without recursively creating symlinks. However this does not seem to fit well into astrality's persistence model.

So in order to get this working I had to:

Let me know what you think, and if there are any issues you forsee with this! Really loving astrality's functionality!

sshashank124 commented 5 years ago

In what way do you mean

However this does not seem to fit well into astrality's persistence model.

It is worth looking into options to allow for symlinking of whole directories.

As for your implementation, I cannot think of anything wrong with it but it doesn't seem ideal to start getting so specific with the conditions in directory globs. We should explore whole dir symlinking options first (maybe starting off from what you experimented with). If that fails, we can fallback on this option

coveralls commented 5 years ago

Pull Request Test Coverage Report for Build 795


Totals Coverage Status
Change from base Build 791: 0.0009%
Covered Lines: 4407
Relevant Lines: 4502

💛 - Coveralls
KeithScheiwiller commented 5 years ago

@sshashank124 As far as I could tell, the persistence model doesn't support directories at all. In fact it looks like it leaves behind directories created as part of symlinking a hierarchy. Correct me if I'm wrong.

sshashank124 commented 5 years ago

One approach would be to also track directories, using the checksum on the tar of the directory. However, that would most probably introduce some other inconsistencies. Let's see what @JakobGM has to say

KeithScheiwiller commented 5 years ago

(Not sure I remember closing this, weird) @sshashank124 Ya, that's something else I tried. I decided to implement it a little more cleanly here if you want to maybe use it as a starting point.