|
|
|
@ -2148,25 +2148,25 @@ bool Session::addTorrent_impl(const std::variant<MagnetUri, TorrentInfo> &source
@@ -2148,25 +2148,25 @@ bool Session::addTorrent_impl(const std::variant<MagnetUri, TorrentInfo> &source
|
|
|
|
|
{ |
|
|
|
|
const TorrentInfo &torrentInfo = std::get<TorrentInfo>(source); |
|
|
|
|
|
|
|
|
|
Q_ASSERT(addTorrentParams.filePaths.isEmpty() || (addTorrentParams.filePaths.size() == torrentInfo.filesCount())); |
|
|
|
|
|
|
|
|
|
const TorrentContentLayout contentLayout = ((loadTorrentParams.contentLayout == TorrentContentLayout::Original) |
|
|
|
|
? detectContentLayout(torrentInfo.filePaths()) : loadTorrentParams.contentLayout); |
|
|
|
|
QStringList filePaths = (!addTorrentParams.filePaths.isEmpty() ? addTorrentParams.filePaths : torrentInfo.filePaths()); |
|
|
|
|
applyContentLayout(filePaths, contentLayout, Utils::Fs::findRootFolder(torrentInfo.filePaths())); |
|
|
|
|
|
|
|
|
|
// if torrent name wasn't explicitly set we handle the case of
|
|
|
|
|
// initial renaming of torrent content and rename torrent accordingly
|
|
|
|
|
if (loadTorrentParams.name.isEmpty()) |
|
|
|
|
{ |
|
|
|
|
QString contentName = torrentInfo.rootFolder(); |
|
|
|
|
if (contentName.isEmpty() && (torrentInfo.filesCount() == 1)) |
|
|
|
|
contentName = Utils::Fs::fileName(torrentInfo.filePath(0)); |
|
|
|
|
QString contentName = Utils::Fs::findRootFolder(filePaths); |
|
|
|
|
if (contentName.isEmpty() && (filePaths.size() == 1)) |
|
|
|
|
contentName = Utils::Fs::fileName(filePaths.at(0)); |
|
|
|
|
|
|
|
|
|
if (!contentName.isEmpty() && (contentName != torrentInfo.name())) |
|
|
|
|
loadTorrentParams.name = contentName; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Q_ASSERT(addTorrentParams.filePaths.isEmpty() || (addTorrentParams.filePaths.size() == torrentInfo.filesCount())); |
|
|
|
|
|
|
|
|
|
const TorrentContentLayout contentLayout = ((loadTorrentParams.contentLayout == TorrentContentLayout::Original) |
|
|
|
|
? detectContentLayout(torrentInfo.filePaths()) : loadTorrentParams.contentLayout); |
|
|
|
|
QStringList filePaths = (!addTorrentParams.filePaths.isEmpty() ? addTorrentParams.filePaths : torrentInfo.filePaths()); |
|
|
|
|
applyContentLayout(filePaths, contentLayout, Utils::Fs::findRootFolder(torrentInfo.filePaths())); |
|
|
|
|
|
|
|
|
|
if (!loadTorrentParams.hasSeedStatus) |
|
|
|
|
{ |
|
|
|
|
const QString actualDownloadPath = useAutoTMM |
|
|
|
|