JakobGM / astrality

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

Symlink loop error on consecutive astrality runs #25

Closed sshashank124 closed 6 years ago

sshashank124 commented 6 years ago

Due to the functionality of moving existing files to filename.ext.bak when symlinking and a file already exists at the target filepath, a weird interaction is occuring.

Suppose a module does the following (simplified to only the relevant lines):

my_module:
  on_startup:
    symlink:
      content: a.txt
      target: ~/a.txt

On the first run, it will create a directory structure such as the following:

~
|- a.txt@  --->  $ASTRALITY_CONFIG_HOME/modules/.../a.txt

$ASTRALITY_CONFIG_HOME
|- modules
   |- ...
      |- a.txt

However, on the second run, since a file already exists in the location of target and since the file is a symlink, it goes into the original directory of $ASTRALITY_CONFIG_HOME/modules/.../ and renames that to a.txt.bak and somehow the final directory structure ends up being:

~
|- a.txt@  --->  $ASTRALITY_CONFIG_HOME/modules/.../a.txt

$ASTRALITY_CONFIG_HOME
|- modules
   |- ...
      |- a.txt@  --->  $ASTRALITY_CONFIG_HOME/modules/.../a.txt     [ symlink loop ]
      |- a.txt.bak                   [ actual file now not symlinked to, from anywhere ]
sshashank124 commented 6 years ago

The PR changes apparently did not fix the issue. Still looking into it

JakobGM commented 6 years ago

In the mean time, I will create the branch bug/symlink and see if I can write a test case for it. I will push it to origin when I have managed to do it.