Improve strip torrent root folder

Fix issue when you rename the "root item" in the "Add New Torrent" dialog
and uncheck "Create subfolder", it will create the subfolder with the
renamed name.
Fix PropertiesWidget first folder is expanded after app restart.
Strip root folder if torrent was added via magnet link.
Fix crash when you get name of torrent without metadata.
This commit is contained in:
Vladimir Golovnev (Glassez) 2016-01-04 16:00:50 +03:00
parent 4b2d8a7941
commit d413bc65ef
6 changed files with 48 additions and 35 deletions

View file

@ -1652,11 +1652,9 @@ bool Session::addTorrent_impl(AddTorrentData addData, const MagnetUri &magnetUri
p = magnetUri.addTorrentParams();
}
else if (torrentInfo.isValid()) {
if (!addData.resumed && !addData.createSubfolder && torrentInfo.filesCount() > 1) {
libtorrent::file_storage files = torrentInfo.files();
files.set_name("");
torrentInfo.remapFiles(files);
}
if (!addData.resumed && !addData.hasRootFolder)
torrentInfo.stripRootFolder();
// Metadata
if (!addData.resumed && !addData.hasSeedStatus)
findIncompleteFiles(torrentInfo, savePath);
@ -3651,6 +3649,7 @@ namespace
torrentData.name = QString::fromStdString(fast.dict_find_string_value("qBt-name"));
torrentData.hasSeedStatus = fast.dict_find_int_value("qBt-seedStatus");
torrentData.disableTempPath = fast.dict_find_int_value("qBt-tempPathDisabled");
torrentData.hasRootFolder = fast.dict_find_int_value("qBt-hasRootFolder");
magnetUri = MagnetUri(QString::fromStdString(fast.dict_find_string_value("qBt-magnetUri")));
torrentData.addPaused = fast.dict_find_int_value("qBt-paused");