-
-
Notifications
You must be signed in to change notification settings - Fork 4.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
Fix some file renaming woes (probably) #20128
Conversation
Thanks! Can you look at https://github.com/qbittorrent/qBittorrent/issues?q=is%3Aopen+is%3Aissue+label%3A%22Data+loss%22 and see which tickets this PR addresses ? |
This PR is stale because it has been 60 days with no activity. This PR will be automatically closed within 7 days if there is no further activity. |
Not stale, I just don’t have the bandwidth to hunt through issues in an unfamiliar repo. |
This PR is stale because it has been 60 days with no activity. This PR will be automatically closed within 7 days if there is no further activity. |
Not stale
|
This PR is stale because it has been 60 days with no activity. This PR will be automatically closed within 7 days if there is no further activity. |
Still not stale <3 |
@@ -53,7 +55,7 @@ void BitTorrent::AbstractFileStorage::renameFile(const Path &oldPath, const Path | |||
if ((renamingFileIndex < 0) && (path == oldPath)) | |||
renamingFileIndex = i; | |||
else if (path == newPath) | |||
throw RuntimeError(tr("The file already exists: '%1'.").arg(newPath.toString())); | |||
throw RuntimeError(tr("The file already exists in this torrent: '%1'.").arg(newPath.toString())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This message is more confusing. There is no indication of what torrent it is referring to.
@@ -130,7 +130,7 @@ bool Path::isRelative() const | |||
|
|||
bool Path::exists() const | |||
{ | |||
return !isEmpty() && QFileInfo::exists(m_pathStr); | |||
return !isValid() && QFileInfo::exists(m_pathStr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is excessive. Please revert it.
@@ -70,6 +72,7 @@ void BitTorrent::AbstractFileStorage::renameFolder(const Path &oldFolderPath, co | |||
throw RuntimeError(tr("The new path is invalid: '%1'.").arg(newFolderPath.toString())); | |||
if (newFolderPath.isAbsolute()) | |||
throw RuntimeError(tr("Absolute path isn't allowed: '%1'.").arg(newFolderPath.toString())); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't make unrelated changes.
@@ -81,7 +84,7 @@ void BitTorrent::AbstractFileStorage::renameFolder(const Path &oldFolderPath, co | |||
if (path.hasAncestor(oldFolderPath)) | |||
renamingFileIndexes.append(i); | |||
else if (path.hasAncestor(newFolderPath)) | |||
throw RuntimeError(tr("The folder already exists: '%1'.").arg(newFolderPath.toString())); | |||
throw RuntimeError(tr("The folder already exists in this torrent: '%1'.").arg(newFolderPath.toString())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This message is more confusing. There is no indication of what torrent it is referring to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw RuntimeError(tr("The folder already exists in this torrent: '%1'.").arg(newFolderPath.toString())); | |
throw RuntimeError(tr("The folder path is the same: '%1'.").arg(newFolderPath.toString())); |
@@ -90,6 +93,6 @@ void BitTorrent::AbstractFileStorage::renameFolder(const Path &oldFolderPath, co | |||
for (const int index : renamingFileIndexes) | |||
{ | |||
const Path newFilePath = newFolderPath / oldFolderPath.relativePathOf(filePath(index)); | |||
renameFile(index, newFilePath); | |||
renameFile(index, newFilePath); // note; if file would be overwritten, we note that is true here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment audience is unclear and doesn't bear any context for the developer. Just don't add it.
renameFile(index, newFilePath); // note; if file would be overwritten, we note that is true here | |
renameFile(index, newFilePath); |
@@ -53,7 +55,7 @@ void BitTorrent::AbstractFileStorage::renameFile(const Path &oldPath, const Path | |||
if ((renamingFileIndex < 0) && (path == oldPath)) | |||
renamingFileIndex = i; | |||
else if (path == newPath) | |||
throw RuntimeError(tr("The file already exists: '%1'.").arg(newPath.toString())); | |||
throw RuntimeError(tr("The file already exists in this torrent: '%1'.").arg(newPath.toString())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps:
throw RuntimeError(tr("The file already exists in this torrent: '%1'.").arg(newPath.toString())); | |
throw RuntimeError(tr("The file path is the same: '%1'.").arg(newPath.toString())); |
This PR is stale because it has been 60 days with no activity. This PR will be automatically closed within 7 days if there is no further activity. |
This PR was closed because it has been stalled for some time with no activity. |
Hullo, new contributer, wanted to avoid others losing data the way I just did!
I added a few new checks that, to my knowlege, will prevent users from renaming files on top of files that exist. While this can be useful for reseeding, it causes instant data loss if qbittorrent has downloaded any part of the existing file.
I also do some cleanup on messages and exists() function.
Reject the PR if you'd prefer to move the functionality to a different place, but I had the itch to hack something up to fix this, and I couldn't resist.
Probably closes a few issues, but I wasn't sure which, and I should get back to final projects.