Curious behavior with symbolic links

I want to understand a curious behavior with symbolic links. Consider machines One and Two. In One I make a directory A with a file a and a directory B with the same file a and another file b:

  One:~$ mkdir A B; touch A/a; cp A/a B; touch B/b; ls -R
  A:
  a
  B:
  a b

I wait until both machines are synchronized. Later I remove directory A and replace it by a symbolic link to B

  One:~$ rm -r A; ln -s B A; ls -R 
  A:
  a b
  B:
  a b

Synchronization fails at Two when it tries to delete A because the directory is not empty.

Two:~$ ls -R 
A:
a
B:
a b

To allow synchronization to complete, I remove the directory A

Two:~$ rm -r A; ls B
a b

After synchronization completes A becomes a symbolic link in machine Two, as expected, but with the undesired consequence that in the process file a disappeared from directory B in both machines, whereas it was deleted from directory A in machine Two where it was not linked to directory B.

One:~$ ls -R
A:
b
B:
b

Two:~$ ls -R
A:
b
B:
b

Is this behavior expected? What should have been the correct procedure to allow completion of the synchronization?

There are currently some bugs around replacing files with dirs with the same name, or dirs with symlinks, and so on. I’m working on rewriting the relevant code, should be done in a couple of releases, as v0.13. Currently you’re better off not doing those kinds of transformations in one step. Sorry about that.

Are you using inotify? Or just plain rescanning?

It looks it fails to pick up on the deletion of A/a, or executes it out of order.

But I think in this case there is nothing like that happening, essentially he’s just removing a directory, hence why it looks suspicious.

OK. I’ll be more careful.

I’m just rescanning every minute. It seems that if I delete A and wait for synchronization of the deletion before making the symbolic link, everything works nicely. The problem is synchronizing both the delete and the symbolic link creation during the same scan.

I think its worth a bug report on github with the steps of reproduction including on when the rescan happens.

Done. Issue 2571. Regards, Luis

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.