-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Prevent unrelated files from being overwritten #7138
Comments
There are three possible variants of the existing file in relation to torrent:
So, in order to make the behavior less "naive", libtorrent could set an error and pause the torrent when any unrelated file is found, thereby preventing unrelated files from being unexpectedly overwritten. This will still allow overwriting such a file if necessary, if the user explicitly wants it (by clearing error and resuming the torrent). |
Apparently, the key action is checking files, so it doesn't matter what it is initiated by, adding a new torrent, moving storage, or just forced rechecking, at the end of it the torrent should get an errored status if at least one unrelated file is found. |
This comment was marked as off-topic.
This comment was marked as off-topic.
How would libtorrent know if a file is "related" or not? |
For example how I outline above; if a file contains non-zero pieces that fail the hash check (where all blocks are non-zero, naturally) |
So if it falls in "errored" state at least in case 4. it would be really better than currently. And I believe it should cover most of regular cases. There also could be some setting for sensitivity level of checking to optionally consider case 3. and case 2. as error. |
It seems like there are edge cases:
Is there a reason these checks couldn't be done in the app, prior to calling The goal seems to be to answer "did the user really mean to do X?". That's ill-defined, and may be different for different apps. Libtorrent's codebase is already huge. Personally I think there needs to be a really compelling reason to extend that codebase with fuzzy logic like this. |
This is completely wrong. The goal is to prevent something that the user definitely does not want (i.e. overwriting the files that are unrelated to torrent and only have the matched names by accident). And in case it is not clear from the context, the point is not to prohibit overwriting files in the cases described above (I agree, it is desirable to have clearer conditions for this), but namely to prevent accidental overwriting of files (anyone can still clear the error and resume the torrent). |
a change that would be simple to make is; if It would support the following cases:
Perhaps a better way would be to add a new flag saying any existing files are to be considered an error. Say, |
This case is not relevant at all. As for 1. and 2. File checking should be done completely as currently and only then some more advanced analysis could be performed. And if it detects any possible unrelated files, then it should prevent them from being overwritten without explicit permission from the user side. That's the whole point. |
You mean it's not relevant to this ticket, right? It is a case that needs to be supported, |
The "explicit permission" could be in the form of a Did you have any other mechanism in mind? |
It isn't a case that needs to be supported. |
It was added as part of this discussion: #5163 |
Sorry, I'm confused. What do you mean? I mentioned that the case of restoring torrents from a previous session (neither with |
Explicit permission to overwrite a "suspicious" files is
No. |
Not native English, tried my best though :) Maybe i am completely missing the obvious here. But we are trying really hard to solve a easy problem the hard way. (With fuzzy detection of related files) Easy solution:
This fixes:
Possible downsides:
As stated, i do not have knowledge about the technical side. But this seems a better and simple solution. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@arvidn Should this be fixed in libtorrent? Yes. Will I be submitting a fix for it in qBittorrent instead? Also yes. Was this issue closed for being "stale" without any good reason? You betchya. |
bumping for re-open |
(This Issue is extracted from discussion
started at qbittorrent/qBittorrent#7146 (comment).)
Currently, when libtorrent starts processing an existing file (either when adding a new torrent, or when moving an existing one with
dont_replace
flag, when the file name matches the name of one of the files belonging to the torrent), it "naively" believes that this file belongs to the torrent. And if, when checking hashes, the hash of some piece does not match, then such a piece is considered not downloaded. Because of this behavior, any unrelated file with the matched name is simply considered by libtorrent as not having any downloaded piece, as a result of which such a file is overwritten by a file from the torrent, which is undesirable behavior from the point of view of users.As mentioned in the linked Issue, it would be nice to make the initial file check smarter, or at least make the behavior described above less "naive".
The text was updated successfully, but these errors were encountered: