qbittorrent / qBittorrent

qBittorrent BitTorrent client
https://www.qbittorrent.org
Other
28.23k stars 3.97k forks source link

Downloading different files with the same name from different torrents overwrites them #7676

Closed oxalfe closed 4 years ago

oxalfe commented 7 years ago

This issue has been reported in 3808 4417 4938 5661 6825, but none are closed, so I would like to know if it's even possible to fix.

Suppose you have two different torrents with the following structure:

ExampleTorrent Size: 523.47 MB Files: 2 AddTime: 2015-02-17 09:09:07

File.wmv 523.47 MB
dummy 0 B

ExampleTorrent Size: 987.54 MB Files: 3 AddTime: 2015-02-12 20:26:06

File.wmv 987.54 MB
dummy 0 B
dummy2 0 B

Both torrents will be downloaded to the same folder, which will cause an error, or if the option "Keep incomplete torrents in:" is activated, one of them will overwrite the other when both finish.

qBittorrent should display some warning, or keep the structure that creates for incomplete torrents.

reyaz006 commented 6 years ago

The real problem is: When I rename the file inside qbt, I expect it to stay like that. I download a second torrent with the file named exactly like the one already present in the folder and in torrents list, I rename it in qbt, to make sure that both files are kept. But it fails to properly do that. It can do that once and I will see that both files are fine. I even pause both torrents to make sure qbt doesn't touch them anymore. But then, at some point, especially after restarting qbt or after PC crash, after qbt is started again, it'll do some processing through those torrents and files. It'll reset the custom file name. It'll wipe one version of the file and will try to download the other version of it from the second torrent.

Right now, the only way to make sure that my downloaded files are safe is to remove corresponding torrent from qbt. This is awful and embarrassing.

dojima commented 6 years ago

Just had this happen to me. This is a major issue. How can it start a torrent download without checking the hash of an identically named file?? This is like torrenting 101, come on...

For now, I guess I just have to use the append .!qB extension option to mitigate the chance that this happens. Awful.

taltamir commented 6 years ago

This is a fairly basic thing that needs fixing. The most basic of fixes is to pop up a question to the user on torrent adding that says there is a collision, asking them if they wish to overwrite, put the torrent in a subfolder, or manually rename the file

Elijas commented 5 years ago

How is this not fixed yet ? Encountered the same bug

EDIT: @thalient Thanks for quick reaction!

More details: The files with the same name get corrupted with each other in the "tmp" category (for incomplete files)

inthebrilliantblue commented 5 years ago

I would like to have an option or checkbox in the settings that enables each torrent to be placed into its own directory that is named as its torrent hash. Sometimes torrents get "updated" with more data, but is still named the same even though its hashes are different.

That, or maybe even a simple yyyy-mm-ddThh-ss-sss date loaded timestamp added in front of the torrents name on the folder. Anything to separate the download locations automatically. Id rather download the same bit of data multiple times than have some data loss because one torrent happens to have the same name as another.

Also, Is there a page for bounties? Id like to put some money towards this.

taltamir commented 4 years ago

@inthebrilliantblue Such an option sounds fine. I would not use it myself as I find it really uncomfortable, but some people prefer it.

That said, implementing such an option is not a substitute for proper collision checking. Especially if it is optional instead of mandatory, such that the issue of name collisions remain for people who disable that option. So such a feature will not be a fix for this bug.

inthebrilliantblue commented 4 years ago

Then what would be a proper way to handle it? Doing checks on actual file hashes instead of the name and deciding from there programmatically?

On Sat, Dec 7, 2019, 2:23 AM Tal Tamir notifications@github.com wrote:

@inthebrilliantblue https://github.com/inthebrilliantblue Such an option sounds fine. I would not use it myself as I find it really uncomfortable, but some people prefer it.

That said, implementing such an option is not a substitute for proper collision checking. Especially if it is optional instead of mandatory.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/qbittorrent/qBittorrent/issues/7676?email_source=notifications&email_token=ACREYOQVRLRTFTTV4EXSFRDQXNMQJA5CNFSM4ECIOLD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGGBGEI#issuecomment-562828049, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACREYOUFZ4SHMN3QL3GP42LQXNMQJANCNFSM4ECIOLDQ .

taltamir commented 4 years ago

Then what would be a proper way to handle it? Doing checks on actual file hashes instead of the name and deciding from there programmatically?

The ideal way to handle it is to make the process of adding a new torrent perform a filename check

If the filename check shows an existing file collision then popup this file [dir/name] already exists, do you want to:

  1. input a new name
  2. place the new torrent in a subfolder
  3. it is the same file, reuse it. - warning: blah blah blah use with care

with an option to set an automatic handler than can automatically do options 1 or 2.

A less optimal but still good way to handle it. Is to automatically do number 2 above when a filename collision is detected

An even less optimal but still viable method is to make your previous suggestion of automatically putting each torrent in a subfolder with its hash a mandatory requirement instead of optional like you suggested.

inthebrilliantblue commented 4 years ago
  1. input a new name

Would be nice, but unhelpful to people who load thousands of torrents.

  1. place the new torrent in a subfolder

Personally I like this, like maybe the torrents use the same named folder but each gets a sub folder. ./sameNamedTorrent/Dup1 ./sameNamedTorrent/Dup2

I wouldnt know what to name the sub folders though, especially in an automated fashion.

  1. it is the same file, reuse it. - warning: blah blah blah use with care

Only really useful if the files are the same, which we shouldn't assume.

with an option to set an automatic handler than can automatically do options 1 or 2.

A less optimal but still good way to handle it. Is to automatically do number 2 above when a filename collision is detected

Would this lead to merged torrent files in the same folder?

An even less optimal but still viable method is to make your previous suggestion of automatically putting each torrent in a subfolder with its hash a mandatory requirement instead of optional like you suggested.

I would like the option of each torrent gets its own unique folder that doesn't get shared with other torrents, even if they have the same name. Which isnt easy to do.

oxalfe commented 4 years ago

I didn’t know this was a duplicate of an existing issue filed way back on 27 Sep 2012 namely #127, @sledgehammer999 last posted on it on 26 Dec 2014 and said

I am actively working on this. And probably no one else. So you can look into it if you want.

However, the issue is still open and no one is assigned to it right now.

inthebrilliantblue commented 4 years ago

127

Interesting that this issue has been ignored for so long. Again I have to ask, does this project have a bug bounty program I can put some money into?

taltamir commented 4 years ago

Would be nice, but unhelpful to people who load thousands of torrents.

I was explicitly stating that qbittorrent offer these as options to the user. This is the option most useful for 99% of users. The 1% that can't use it should just not choose it, hence 3 options.

Only really useful if the files are the same, which we shouldn't assume.

We are not assuming, we are being explicitly told so by the user after they were explicitly warned.

I would like the option of each torrent gets its own unique folder that doesn't get shared with other torrents, even if they have the same name. Which isnt easy to do.

It is super easy to do. string foldername if torrent has 1 single top level folder, set foldername to it if torrent has 1 single top level file, set foldername to the same name as the file minus extension else use the torrent name if foldername already exists in target directory, change it create foldername in target directory immediately when the torrent is added, the contents can be moved when completed from the temp directory

as for how to change it. windows uses the system of name name (1) name (2) name (3)

other torrent programs use the system of name name-1 name-2 name-3

etc. naturally the change folder name function needs to recursively check those until it finds a free number

thalieht commented 4 years ago

Duplicate of #127