jdupes icon indicating copy to clipboard operation
jdupes copied to clipboard

Hard linking needs to link symlink targets when used with -s (not the symlinks themselves)

Open Chaz6 opened this issue 4 years ago • 0 comments
trafficstars

Currently when using the option -s, the symlinks are not fully de-referenced (maybe not the correct terminology). Here is a simple example.

cd /tmp
mkdir -p jdupes-test && cd jdupes-test
mkdir -p source
mkdir -p target
echo "a" > target/a1
echo "a" > target/a2
echo "b" > target/b1
echo "b" > target/b2
cd source
ln -s ../target/a1
ln -s ../target/a2
ln -s ../target/b1
ln -s ../target/b2
jdupes -L -s -r .

The current behavior results in the following:-

$ ls -l /tmp/jdupes-test/source
# output abridged
source/a1 -> ../target/a1
source/a2 -> ../target/a1
source/b1 -> ../target/b1
source/b2 -> ../target/b1
$ stat /tmp/jdupes-test/target/*
# output abridged
File: target/a1
Links: 1
File: target/a2
Links: 1
File: target/b1
Links: 1
File: target/b2
Links: 1

The target files are not deduplicated, and each have 1 link each.

This is the behaviour I desire:-

$ ls -l /tmp/jdupes-test/source
# output abridged
source/a1 -> ../target/a1
source/a2 -> ../target/a2
source/b1 -> ../target/b1
source/b2 -> ../target/b2
$ stat /tmp/jdupes-test/target/*
# output abridged
File: target/a1
Links: 2
File: target/a2
Links: 2
File: target/b1
Links: 2
File: target/b2
Links: 2

The reason for not running jdupes directly on the target folder is because the folder contains millions of files, and I only want to operate upon a subset at any given time.

Chaz6 avatar Feb 14 '21 13:02 Chaz6