Closed kalouantonis closed 7 years ago
Hard symlinks
Well, just hardlinks. But hardlinking directories is forbidden, at least on linux.
mkdir a
ln a b
# ln: a: hard link not allowed for directory
-d, -F, --directory
allow the superuser to attempt to hard link directories (note: will probably fail due to system restrictions, even
for the superuser)
ln -F a b
# ln: failed to create hard link 'b' => 'a': Operation not permitted
sudo ln -F a b
# ln: failed to create hard link 'b' => 'a': Operation not permitted
Apparently, OSX Timemachine supports it though (see last para)
Both types of links seem to cause issues in certain environments, and I merged far too quickly on top of "works for me" thinking (OSX). I'll deploy 0.3.2-SNAPSHOT with this change now.
Thanks for pressing the issue and submitting the PR
If you're doing recursive traversal, what you might want to do instead is create a hardlink-tree.
That is ( pseudocode )
linktree[ src, dest ]:
src.file ?
hardlink src -> dest
src.dir ?
mkdir dest
src.children.each |child|:
linktree src + '/' + child, dest + '/' + child
This is basically mimicking what
cp --link --recursive src dest
Does.
mkdir test
cd test
mkdir -p src/l1/l2/l3
touch src/{l1,l1/l2,l1/l2/l3}/something
cp --verbose --link --recursive src dest
# 'src' -> 'dest'
# 'src/l1' -> 'dest/l1'
# 'src/l1/something' -> 'dest/l1/something'
# 'src/l1/l2' -> 'dest/l1/l2'
# 'src/l1/l2/something' -> 'dest/l1/l2/something'
# 'src/l1/l2/l3' -> 'dest/l1/l2/l3'
# 'src/l1/l2/l3/something' -> 'dest/l1/l2/l3/something'
find -ls
# 15016033 4 drwxr-xr-x 4 kent kent 4096 Jun 23 19:27 .
# 15016040 4 drwxr-xr-x 3 kent kent 4096 Jun 23 19:27 ./dest
# 15016042 4 drwxr-xr-x 3 kent kent 4096 Jun 23 19:27 ./dest/l1
# 15016043 4 drwxr-xr-x 3 kent kent 4096 Jun 23 19:27 ./dest/l1/l2
# 15016044 4 drwxr-xr-x 2 kent kent 4096 Jun 23 19:27 ./dest/l1/l2/l3
# 14759827 0 -rw-r--r-- 2 kent kent 0 Jun 23 19:27 ./dest/l1/l2/l3/something
# 14759806 0 -rw-r--r-- 2 kent kent 0 Jun 23 19:27 ./dest/l1/l2/something
# 14759805 0 -rw-r--r-- 2 kent kent 0 Jun 23 19:27 ./dest/l1/something
# 15016035 4 drwxr-xr-x 3 kent kent 4096 Jun 23 19:26 ./src
# 15016036 4 drwxr-xr-x 3 kent kent 4096 Jun 23 19:27 ./src/l1
# 15016038 4 drwxr-xr-x 3 kent kent 4096 Jun 23 19:27 ./src/l1/l2
# 15016039 4 drwxr-xr-x 2 kent kent 4096 Jun 23 19:27 ./src/l1/l2/l3
# 14759827 0 -rw-r--r-- 2 kent kent 0 Jun 23 19:27 ./src/l1/l2/l3/something
# 14759806 0 -rw-r--r-- 2 kent kent 0 Jun 23 19:27 ./src/l1/l2/something
# 14759805 0 -rw-r--r-- 2 kent kent 0 Jun 23 19:27 ./src/l1/something
You'll note the inode numbers of the files are the same in both trees, but the directory inode numbers are different.
Though, you'll possibly also need to consider the possibilities that:
Hard symlinks are causing the tests to fail: https://circleci.com/gh/crisptrutski/boot-cljs-test/97 and break release 0.3.1.