[FR]: Change the logic of HardLinks detection to ignore hardlinks detected in the same root_dir #291
Labels
feature request
New feature or request
status:added-to-develop
Feature Request or Bug Fix is in Develop
Is your feature request related to a problem? Please elaborate.
Currently the logic for no_hl is based on the number of hardlinks in existence. If less than two hardlinks exist, the torrent will be tagged as
no_hl
.This can be an issue if two torrents have different layouts (say
/torrents/myMovie/myMovie (2023).mkv
and/torrents/myMovie (2023) - Special Edition.mkv
being the same file). In this case the two torrents would never be marked as no_hl as there is always more than a single hardlink (even though for the purpose of torrent management we'd consider that file as not hardlinked).Describe the solution you'd like
The logic for hardlink detection can be changed slightly.
Before going through the hardlinks, it should be possible to count the number of occurences of each inode in
root_dir
.Traversing the entire folder is similar to the operation done when looking for orphaned files.
Then when looking up the number of hardlinks for each torrent, rather than applying the logic
if os.stat(file).st_nlink > 1
, it should be possible to change the logic toif os.stat(file).st_nlink - inodes_count[os.stat(file).st_ino] > 0:
, that would effectively update the logic.Original logic:
Suggested logic:
Does your solution involve any of the following?
Describe alternatives you've considered
Alternatives have been suggested in the past: #208
This approach is a bit "cleaner" as it doesn't require the introduction of new "knowledge" in qbitmanage, simply assuming that the existence of hardlinks outside of
root_dir
can do wonders.Who will this benefit?
With the new version of cross-seed, "data-detected" torrents can be created via hardlinks, it will lead to an increase in cases of "torrents that people might expect to see as no_hl not being treated as such".
Additional Information
No response
The text was updated successfully, but these errors were encountered: