Rename torrent if content was initially renamed

Closes #8910.
This commit is contained in:
Vladimir Golovnev (Glassez) 2018-05-19 09:41:33 +03:00
commit a54f57611c
No known key found for this signature in database
GPG key ID: 52A2C7DEE2DFA6F7
3 changed files with 33 additions and 13 deletions

View file

@ -2149,12 +2149,26 @@ bool Session::addTorrent_impl(AddTorrentData addData, const MagnetUri &magnetUri
p = magnetUri.addTorrentParams();
}
else if (torrentInfo.isValid()) {
if (!addData.resumed && !addData.hasRootFolder)
torrentInfo.stripRootFolder();
if (!addData.resumed) {
if (!addData.hasRootFolder)
torrentInfo.stripRootFolder();
// Metadata
if (!addData.hasSeedStatus)
findIncompleteFiles(torrentInfo, savePath);
// if torrent name wasn't explicitly set we handle the case of
// initial renaming of torrent content and rename torrent accordingly
if (addData.name.isEmpty()) {
QString contentName = torrentInfo.rootFolder();
if (contentName.isEmpty() && (torrentInfo.filesCount() == 1))
contentName = torrentInfo.fileName(0);
if (!contentName.isEmpty() && (contentName != torrentInfo.name()))
addData.name = contentName;
}
}
// Metadata
if (!addData.resumed && !addData.hasSeedStatus)
findIncompleteFiles(torrentInfo, savePath);
p.ti = torrentInfo.nativeInfo();
hash = torrentInfo.hash();
}