Rename file will overwrite existing file with same name which is not part of torrent #14173

Open
opened 2026-02-22 00:46:21 -05:00 by deekerman · 12 comments
Owner

Originally created by @ted423 on GitHub (Dec 31, 2022).

qBittorrent & operating system versions

qBittorrent: 4.5.0 x64
Operating system: Ubuntu 22.04.1 LTS
Qt: 5.15.3
libtorrent-rasterbar: 2.0.8.0

What is the problem?

rename the filename in content.

two torrent
image
image

Steps to reproduce

I have all first pic's file and want recheck the secound pic's torrent

false to rename "Cars.2.2011.Hybrid.1080p.BluRay.x264-EbP.mkv" to "Cars Toon Air Mater 1080p BluRay x264-EbP.mkv"
than rename the "Cars Toon Air Mater 1080p BluRay x264-EbP.mkv" back to "Cars 2 2011 Hybrid 1080p BluRay x264-EbP.mkv"
the 7.79GiB file disapeared

Additional context

No response

Log(s) & preferences file(s)

No response

Originally created by @ted423 on GitHub (Dec 31, 2022). ### qBittorrent & operating system versions qBittorrent: 4.5.0 x64 Operating system: Ubuntu 22.04.1 LTS Qt: 5.15.3 libtorrent-rasterbar: 2.0.8.0 ### What is the problem? rename the filename in content. two torrent ![image](https://user-images.githubusercontent.com/7042766/210143707-7486deff-ec30-4085-adfd-f32621060216.png) ![image](https://user-images.githubusercontent.com/7042766/210143758-2fb93b13-db09-4ef9-92e6-8d80897667dc.png) ### Steps to reproduce I have all first pic's file and want recheck the secound pic's torrent false to rename "Cars.2.2011.Hybrid.1080p.BluRay.x264-EbP.mkv" to "Cars Toon Air Mater 1080p BluRay x264-EbP.mkv" than rename the "Cars Toon Air Mater 1080p BluRay x264-EbP.mkv" back to "Cars 2 2011 Hybrid 1080p BluRay x264-EbP.mkv" the 7.79GiB file disapeared ### Additional context _No response_ ### Log(s) & preferences file(s) _No response_
Author
Owner

@ted423 commented on GitHub (Dec 31, 2022):

rename the "Cars Toon Air Mater 1080p BluRay x264-EbP.mkv" back to "Cars 2 2011 Hybrid 1080p BluRay x264-EbP.mkv"
make the 432.2Mib file overwrite the "Cars 2 2011 Hybrid 1080p BluRay x264-EbP.mkv"(7.79GiB) though the file can't hash in secound torrent

@ted423 commented on GitHub (Dec 31, 2022): rename the "Cars Toon Air Mater 1080p BluRay x264-EbP.mkv" back to "Cars 2 2011 Hybrid 1080p BluRay x264-EbP.mkv" make the 432.2Mib file overwrite the "Cars 2 2011 Hybrid 1080p BluRay x264-EbP.mkv"(7.79GiB) though the file can't hash in secound torrent
Author
Owner

@thalieht commented on GitHub (Dec 31, 2022):

First of all please wrap filenames in ` ` or " " because it's hard to distinguish where they start/end among plain text.
What i understood is that you renamed a file to the same name of an existing file in that folder right? I get "Failed to update name" when i try to do that.

@thalieht commented on GitHub (Dec 31, 2022): First of all please wrap filenames in \` \` or " " because it's hard to distinguish where they start/end among plain text. What i understood is that you renamed a file to the same name of an existing file in that folder right? I get "Failed to update name" when i try to do that.
Author
Owner

@ted423 commented on GitHub (Jan 1, 2023):

First of all please wrap filenames in or " " because it's hard to distinguish where they start/end among plain text. What i understood is that you renamed a file to the same name of an existing file in that folder right? I get "Failed to update name" when i try to do that.

added ".

for torrent 2, is not hashed. the first wrong step make the filename same as the exist small one. and step 2 make the small file to overwrite other one.

I had meet this situation before,maybe i make a screen record when I had time

@ted423 commented on GitHub (Jan 1, 2023): > First of all please wrap filenames in ` ` or " " because it's hard to distinguish where they start/end among plain text. What i understood is that you renamed a file to the same name of an existing file in that folder right? I get "Failed to update name" when i try to do that. added ". for torrent 2, is not hashed. the first wrong step make the filename same as the exist small one. and step 2 make the small file to overwrite other one. I had meet this situation before,maybe i make a screen record when I had time
Author
Owner

@ted423 commented on GitHub (Jan 5, 2023):

I found same on GUI

@ted423 commented on GitHub (Jan 5, 2023): I found same on GUI
Author
Owner

@ted423 commented on GitHub (Jan 5, 2023):

2023-01-05 17-18-57.zip

@ted423 commented on GitHub (Jan 5, 2023): [2023-01-05 17-18-57.zip](https://github.com/qbittorrent/qBittorrent/files/10350946/2023-01-05.17-18-57.zip)
Author
Owner

@stalkerok commented on GitHub (Aug 7, 2025):

2023-01-05 17-18-57.zip

Unzip (for convenience)

https://github.com/user-attachments/assets/88390fab-670e-4a61-ae59-d21d5f67c592

@stalkerok commented on GitHub (Aug 7, 2025): > [2023-01-05 17-18-57.zip](https://github.com/qbittorrent/qBittorrent/files/10350946/2023-01-05.17-18-57.zip) Unzip (for convenience) https://github.com/user-attachments/assets/88390fab-670e-4a61-ae59-d21d5f67c592
Author
Owner

@glassez commented on GitHub (Aug 7, 2025):

I can't imagine why libtorrent behaves this way. Maybe we can convince they that "fail if exists" strategy is more appropriate for renaming files? Unfortunately libtorrent doesn't provide us with corresponding option (unlike "move storage" case).
(Of course we could work around it at qBittorrent level.)

@glassez commented on GitHub (Aug 7, 2025): I can't imagine why `libtorrent` behaves this way. Maybe we can convince they that "fail if exists" strategy is more appropriate for renaming files? Unfortunately `libtorrent` doesn't provide us with corresponding option (unlike "move storage" case). (Of course we could work around it at qBittorrent level.)
Author
Owner

@ted423 commented on GitHub (Aug 7, 2025):

I'm not sure if this is the right way to handle it, because we're dealing with a file that has 0% verification. I'm uncertain whether we should ask the user to skip the actual disk file operations, My situation was caused by a mistake, and while I understand this might be a rare case, the subsequent risk of overwriting files is dangerous.
Alternatively, we could just throw an error directly if the file already exists, letting the user handle it by re-adding the torrent or finding another solution. I'm also worried that a user might accidentally paste a path and overwrite an important file.

@ted423 commented on GitHub (Aug 7, 2025): I'm not sure if this is the right way to handle it, because we're dealing with a file that has 0% verification. I'm uncertain whether we should ask the user to skip the actual disk file operations, My situation was caused by a mistake, and while I understand this might be a rare case, the subsequent risk of overwriting files is dangerous. Alternatively, we could just throw an error directly if the file already exists, letting the user handle it by re-adding the torrent or finding another solution. I'm also worried that a user might accidentally paste a path and overwrite an important file.
Author
Owner

@Dnkhatri commented on GitHub (Aug 8, 2025):

If we add a torrent and a file with the same name exists qbittorrent tries to check against the file if it is different overwrites it. This essentially something similar so if the filename check is added wont it break this in qbittorrent

@Dnkhatri commented on GitHub (Aug 8, 2025): If we add a torrent and a file with the same name exists qbittorrent tries to check against the file if it is different overwrites it. This essentially something similar so if the filename check is added wont it break this in qbittorrent
Author
Owner

@glassez commented on GitHub (Aug 10, 2025):

I can't imagine why libtorrent behaves this way. Maybe we can convince they that "fail if exists" strategy is more appropriate for renaming files?

https://github.com/arvidn/libtorrent/issues/8008

@glassez commented on GitHub (Aug 10, 2025): > I can't imagine why `libtorrent` behaves this way. Maybe we can convince they that "fail if exists" strategy is more appropriate for renaming files? https://github.com/arvidn/libtorrent/issues/8008
Author
Owner

@ted423 commented on GitHub (Aug 11, 2025):

If we add a torrent and a file with the same name exists qbittorrent tries to check against the file if it is different overwrites it. This essentially something similar so if the filename check is added wont it break this in qbittorrent

I don't think they are quite the same, because the phenomenon you mentioned is that a file has the same name as an existing file in the torrent. Typically, users need to be aware that files with the same name can actually be different. And the software also performs a check first; it doesn't overwrite directly.
On the other hand, the phenomenon I'm talking about is when the software uses a file that completely fails validation to directly overwrite a correct, existing file.
Of course, I imagine that a file that passes validation could also overwrite any other file in the same folder without warning. This could also be a problem. But personally, I would categorize that more as a user operation issue.
Also, I think glassez's opinion is to return failed directly instead of asking the user, and I feel that is probably better.

@ted423 commented on GitHub (Aug 11, 2025): > If we add a torrent and a file with the same name exists qbittorrent tries to check against the file if it is different overwrites it. This essentially something similar so if the filename check is added wont it break this in qbittorrent I don't think they are quite the same, because the phenomenon you mentioned is that a file has the same name as an existing file in the torrent. Typically, users need to be aware that files with the same name can actually be different. And the software also performs a check first; it doesn't overwrite directly. On the other hand, the phenomenon I'm talking about is when the software uses a file that completely fails validation to directly overwrite a correct, existing file. Of course, I imagine that a file that passes validation could also overwrite any other file in the same folder without warning. This could also be a problem. But personally, I would categorize that more as a user operation issue. Also, I think glassez's opinion is to return failed directly instead of asking the user, and I feel that is probably better.
Author
Owner

@glassez commented on GitHub (Aug 12, 2025):

Also, I think glassez's opinion is to return failed directly instead of asking the user, and I feel that is probably better.

Above, I only talked about the case of renaming files of an already added torrent. I believe that in the vast majority of cases it would be used specifically for renaming files. Another possible use case is to "map an existing file" - it's not currently supported anyway (at least without additional user actions).

As for the case of renaming files when adding a torrent, it is much more complicated, since "mapping an existing file" is one of its regular uses so we can't just "fail on exists" unconditionally. I'm currently considering ways to solve this problem.

@glassez commented on GitHub (Aug 12, 2025): > Also, I think glassez's opinion is to return failed directly instead of asking the user, and I feel that is probably better. Above, I only talked about the case of renaming files of an already added torrent. I believe that in the vast majority of cases it would be used specifically for renaming files. Another possible use case is to "map an existing file" - it's not currently supported anyway (at least without additional user actions). As for the case of renaming files when adding a torrent, it is much more complicated, since "mapping an existing file" is one of its regular uses so we can't just "fail on exists" unconditionally. I'm currently considering ways to solve this problem.
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#14173
No description provided.