Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR]: Change the logic of HardLinks detection to ignore hardlinks detected in the same root_dir #291

Closed
2 tasks
ColinHebert opened this issue May 19, 2023 · 1 comment · Fixed by #301
Closed
2 tasks
Assignees
Labels
feature request New feature or request status:added-to-develop Feature Request or Bug Fix is in Develop

Comments

@ColinHebert
Copy link

ColinHebert commented May 19, 2023

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 to if os.stat(file).st_nlink - inodes_count[os.stat(file).st_ino] > 0:, that would effectively update the logic.

Original logic:

no_hl means there are no hard links to that file (at all)

Suggested logic:

no_hl means that there are no hard links to that file outside of the folder qbitmanage already manages

Does your solution involve any of the following?

  • New config option
  • New command option

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

@ColinHebert ColinHebert added the feature request New feature or request label May 19, 2023
@bobokun
Copy link
Collaborator

bobokun commented May 20, 2023

Thank you for the suggestion and for coming up with this logic. I've been trying to think of a way of figuring this out without having to mount the media library in order to determine hardlinks. This method is a much better approach. I've pushed a change out to develop branch, feel free to test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request status:added-to-develop Feature Request or Bug Fix is in Develop
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants