JakobGM / astrality

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

When comparing symlinks to symlinks, the content should also be resolved. #88

Closed Helvethor closed 5 years ago

Helvethor commented 6 years ago

I had this case: a module (vim) containing two files (init.vim and vimrc), vimrc being a symlink -> init.vim. Uppon stow, \~/.vim/vimrc points to the correct file (modules/vim/.../vimrc). Uppon restow, the symlink action wouldn't recognize the link was already there because only the target part was being resolved (~/.vim/vimrc -> modules/vim/.../vimrc -> modules/vim/.../init.vim) and compared against the content (modueles/vim/.../vimrc). This produced an error on line 402 uppon re-symlinking.

I'm not sure this is the best solution and that it doesn't introduces new bugs.

coveralls commented 6 years ago

Pull Request Test Coverage Report for Build 645


Files with Coverage Reduction New Missed Lines %
astrality/module.py 3 97.38%
<!-- Total: 3 -->
Totals Coverage Status
Change from base Build 553: -0.07%
Covered Lines: 4405
Relevant Lines: 4500

💛 - Coveralls
sshashank124 commented 6 years ago

In your particular setup, there is no need to perform a "double-symlink". You should only need to have an "init.vim" file in your modules directory. Then, you can symlink both ~/.vim/vimrc and ~/.config/nvim/init.vim directly to the modules/vim/.../init.vim file without ever having to create a modules/vim/.../vimrc file

Helvethor commented 6 years ago

I agree that this particular case is not very interesting. I have another case thought: I store many wallpapers in a directory and there is always one symlink called "wallpaper" pointing at my current favorite wallpaper file. One could argue that there is a better way to handle this other case, but somehow I feel like it would avoid headaches to others who happen to use symlink inside their dots.

sshashank124 commented 6 years ago

@Helvethor I have tried replicating your original issue but cannot seem to get the same error.

I created a module test which contains 2 files (a.txt and b.txt). a.txt contains some text and b.txt is a symlink to a.txt.

.../astrality/modules/test
 |
 |-- a.txt
 '-- b.txt -> a.txt

Then I perform a symlink for the b.txt file as defined by the following modules.yml file.

test:
  on_startup:
    symlink:
      - content: b.txt
        target: $HOME/test/b.txt

and it correctly creates a symlink b.txt as follows in the $HOME/test directory

$HOME/test
 |
 '-- b.txt -> .../astrality/modules/test/b.txt

It also works correctly upon subsequent re-runs of the astrality command.

Let's discuss this further in the Gitter room so that we can have an easier conversation.

Helvethor commented 6 years ago

The difference between your setup and mine is that you define the action on a single file. My action was something like this:

stow:
    content: 'modules/nvim/stow'
    templates: 't\.(.+)'
    target: '~/.config/nvim'

It seems like the file handling is not quite the same, although I have not investigated it further.