mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-03-02 22:57:32 -05:00
Moved files-auto find instead of mark them as Missing. Automatically detect where they were moved especially if its on the same volume. #15985
Labels
No labels
Accessibility
AppImage
Bounty
Build system
CI
Can't reproduce
Code cleanup
Confirmed bug
Confirmed bug
Core
Crash
Data loss
Discussion
Docker
Documentation
Duplicate
Feature
Feature request
Feature request
Feature request
Filters
Flatpak
GUI
Has workaround
I2P
Invalid
Libtorrent
Look and feel
Meta
NSIS
Network
Not an issue
OS: *BSD
OS: Linux
OS: Windows
OS: macOS
PPA
Performance
Project management
Proxy/VPN
Qt bugs
Qt6 compat
RSS
Search engine
Security
Temp folder
Themes
Translations
Triggers
Waiting diagnosis
Waiting info
Waiting upstream
Waiting web implementation
Watched folders
WebAPI
WebUI
autoCloseOldIssue
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/qBittorrent#15985
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ghost on GitHub (Aug 14, 2024).
Suggestion
Moved files-auto find instead of mark them as Missing. Automatically detect where they were moved especially if its on the same volume.
Use case
"Alignment."
Alignment to current Information+AI theories.
Auto-handle files.
Fool-proof seeding.
Intelligently manage torrent data coming and going to the system.
Reduce maintenance.
Provide a more human-friendly less mess-prone system to endusers.
Extra info/examples/attachments
win11 26120.14501 qbt 4.6.5 stable Qt: 6.4.3
Libtorrent: 2.0.11.0
Boost: 1.85.0
OpenSSL: 1.1.1w
@thalieht commented on GitHub (Aug 14, 2024):
Duplicate of #6520
@ghost commented on GitHub (Aug 14, 2024):
@thalieht thats not the same request that tool is for my other Feature Request that I raised
This one would be better done by NTFS ID tracking and USN Journal checking.
Or a more stupider directory traversal to match a directory name only should also be sufficient to satisfy this scenario.
To track where a directory has been moved on the same NTFS volume using the Win32 API, you can utilize the USN (Update Sequence Number) Journal or the ReadDirectoryChangesW function.
Using USN Journal
The USN Journal provides a record of changes made to files and directories on an NTFS volume. When a directory is moved, it generates two USN records: one for the old parent directory and one for the new parent directory. This allows you to track the movement of the directory.
Using ReadDirectoryChangesW
The
ReadDirectoryChangesWfunction can monitor changes in a directory, including renames (which is how moves within the same volume are treated). Here's a basic example:Using GetFileInformationByHandle
You can also use
GetFileInformationByHandleto get the file index, which remains the same even if the file or directory is moved within the same volume².Would you like more details on any of these methods?
Source: Conversation with Copilot, 8/14/2024
(1) How to detect a file move under win32 NTFS? - Stack Overflow. https://stackoverflow.com/questions/35242661/how-to-detect-a-file-move-under-win32-ntfs.
(2) How to see if a subfile of a directory has changed. https://stackoverflow.com/questions/56682/how-to-see-if-a-subfile-of-a-directory-has-changed.
(3) win32/desktop-src/FileIO/distributed-link-tracking-and-object ... - GitHub. https://github.com/MicrosoftDocs/win32/blob/docs/desktop-src/FileIO/distributed-link-tracking-and-object-identifiers.md.
@ghost commented on GitHub (Aug 14, 2024):
The previous may not be correct Gemini didnt like it at all I dont know why.
Heres another by Bing Copilot again:
Sure! Here's a modern C++ variant that uses the C++ Standard Library and RAII principles to make the code more concise and safer:
Example Code in C++
Explanation
This modern C++ approach is more concise and leverages the power of the C++ Standard Library to handle file system operations efficiently.
Would you like any further details or modifications to this code?
@ghost commented on GitHub (Aug 14, 2024):
Gemini liked this one:
Improving the Code: Considerations and Enhancements
Excellent code! The use of
std::filesystemis spot on for modern C++ file system operations.Potential Enhancements:
Error Handling:
Case-Insensitive Search (Windows):
Recursive Depth Control:
Performance Optimization:
Additional Information:
Revised Code with Enhancements:
This revised code incorporates error handling, a depth limit, and returns the found path as an optional. It also demonstrates how to use
std::numeric_limitsfor a default maximum depth.Would you like to explore any of these enhancements further or discuss other requirements?
@ghost commented on GitHub (Aug 14, 2024):
Yes, you can achieve similar simplicity in qBittorrent's C++ codebase by leveraging the C++ Standard Library and modern C++ features. Here's a conceptual approach to finding a missing folder within qBittorrent:
Example Code in Modern C++
Explanation
Integration with qBittorrent
To integrate this functionality into qBittorrent, you would:
find_directoryfunction in the appropriate part of the qBittorrent codebase.This approach leverages modern C++ features to keep the code concise and efficient, making it easier to maintain and understand.
Would you like more details on integrating this into qBittorrent or any other assistance?
Source: Conversation with Copilot, 8/14/2024
(1) QBittorrent downloads missing - QNAP NAS Community Forum. https://forum.qnap.com/viewtopic.php?t=165110.
(2) After restarting, qBittorrent(run in portable mode) report `Missing .... https://github.com/qbittorrent/qBittorrent/issues/17437.
(3) I/O error because of "missing" files · Issue #7917 · qbittorrent .... https://github.com/qbittorrent/qBittorrent/issues/7917.
(4) using an incomplete folder and moving the torrents causes 'missing .... https://github.com/qbittorrent/qBittorrent/issues/3223.
(5) How do I fix Missing Files error? : r/qBittorrent - Reddit. https://www.reddit.com/r/qBittorrent/comments/1bp23og/how_do_i_fix_missing_files_error/.
(6) undefined. https://github.com/qbittorrent/qBittorrent/actions/runs/2737055361.
@ghost commented on GitHub (Aug 14, 2024):
Certainly! C++20 introduces several new features that can make the code even more concise and expressive. Here's an updated version of the directory search function using C++20 features:
Example Code in C++20
Explanation
Integration with qBittorrent
To integrate this functionality into qBittorrent:
find_directoryfunction in the appropriate part of the qBittorrent codebase.This approach leverages modern C++20 features to keep the code concise, efficient, and easy to understand.
Would you like more details on integrating this into qBittorrent or any other assistance?
@thalieht commented on GitHub (Aug 14, 2024):
I'll... let the devs decide then.
@Patty-OFurniture commented on GitHub (Aug 16, 2024):
I'm not sure what many of those clarifications achieve.. Having implemented both infohash v1 processing and a filewatcher, I can tell you I would just close this one. If you need a torrent client to be aware of moves, do it in the torrent client. Otherwise, external solutions exist specific to your needs.
For this one, I would recommend doing a list of the relative filenames you expect, and then process "dir /b /s" output with a UNION, and a percentage threshold to determine if a subdir holds what you expect. Nothing will be more efficient.
I don't think a cross-platform solution is possible, or if it is possible, I would not want someone doing it, who is basically creating a UI over libtorrent. Not to cast aspersions, it's just that it won't be in any normal developer's wheelhouse. You need a special kind of person to be interested in this.
A filesystem watcher running at all times, especially if it is built in to and therefore requires the torrent client to be running all the time, is not a good solution at all.
I don't find support for "use GetFileInformationByHandle to get the file index, which remains the same" in the references provided. Reference 2 is the Windows filesystem watcher, and Reference 3 does not explicitly state that fact. And 3 refers to link tracking, as in does this point to the same object. GetFileInformationByHandle reference states "You can compare the VolumeSerialNumber and FileIndex members returned in the BY_HANDLE_FILE_INFORMATION structure to determine if two paths map to the same target" as in, right now, not were they once the same file.
NTFS journaling is the only real solution other than filesystem watcher, and besides being obviously platform and filesystem specific, it will not preserve changes to a different volume. So if you download on C: and move to D: on the same physical disk, I don't see how it's going to track that change based on the little reading I did until I got bored.
I'll stop now with a warning: be very careful about any AI assist, you have to understand enough to know if it's good advice as of today. Be careful as of today and consider whether the advice is current aka still the best or a better option exists.
@ghost commented on GitHub (Aug 16, 2024):
Info Updated and Closed. Other features that use similar API are more important for now.