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

Closed
opened 2026-02-21 18:17:38 -05:00 by deekerman · 13 comments
Owner

Originally created by @oxalfe on GitHub (Nov 4, 2017).

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.

Originally created by @oxalfe on GitHub (Nov 4, 2017). This issue has been reported in [3808](https://github.com/qbittorrent/qBittorrent/issues/3808) [4417](https://github.com/qbittorrent/qBittorrent/issues/4417) [4938](https://github.com/qbittorrent/qBittorrent/issues/4938) [5661](https://github.com/qbittorrent/qBittorrent/issues/5661) [6825](https://github.com/qbittorrent/qBittorrent/issues/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.
deekerman 2026-02-21 18:17:38 -05:00
Author
Owner

@reyaz006 commented on GitHub (Dec 6, 2017):

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.

@reyaz006 commented on GitHub (Dec 6, 2017): 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.
Author
Owner

@dojima commented on GitHub (Mar 8, 2018):

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.

@dojima commented on GitHub (Mar 8, 2018): 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.
Author
Owner

@taltamir commented on GitHub (Sep 27, 2018):

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

@taltamir commented on GitHub (Sep 27, 2018): 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
Author
Owner

@Elijas commented on GitHub (Apr 27, 2019):

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)

@Elijas commented on GitHub (Apr 27, 2019): 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)
Author
Owner

@inthebrilliantblue commented on GitHub (Sep 25, 2019):

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.

@inthebrilliantblue commented on GitHub (Sep 25, 2019): 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.
Author
Owner

@taltamir commented on GitHub (Dec 7, 2019):

@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.

@taltamir commented on GitHub (Dec 7, 2019): @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.
Author
Owner

@inthebrilliantblue commented on GitHub (Dec 7, 2019):

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
.

@inthebrilliantblue commented on GitHub (Dec 7, 2019): 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> > . >
Author
Owner

@taltamir commented on GitHub (Dec 8, 2019):

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.

@taltamir commented on GitHub (Dec 8, 2019): > 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.
Author
Owner

@inthebrilliantblue commented on GitHub (Dec 16, 2019):

  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.

@inthebrilliantblue commented on GitHub (Dec 16, 2019): > 1. input a new name Would be nice, but unhelpful to people who load thousands of torrents. > 2. 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. > 3. 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.
Author
Owner

@oxalfe commented on GitHub (Dec 17, 2019):

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.

@oxalfe commented on GitHub (Dec 17, 2019): I didn’t know this was a duplicate of an existing issue filed way back on 27 Sep 2012 namely [#127](https://github.com/qbittorrent/qBittorrent/issues/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.
Author
Owner

@inthebrilliantblue commented on GitHub (Dec 18, 2019):

#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?

@inthebrilliantblue commented on GitHub (Dec 18, 2019): > #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?
Author
Owner

@taltamir commented on GitHub (Dec 19, 2019):

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

@taltamir commented on GitHub (Dec 19, 2019): > 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
Author
Owner

@thalieht commented on GitHub (Sep 13, 2020):

Duplicate of #127

@thalieht commented on GitHub (Sep 13, 2020): Duplicate of #127
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/qBittorrent#6230
No description provided.