mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
parent
2da39e2fbb
commit
84a8158aa2
@ -2148,18 +2148,6 @@ bool Session::addTorrent_impl(const std::variant<MagnetUri, TorrentInfo> &source
|
|||||||
{
|
{
|
||||||
const TorrentInfo &torrentInfo = std::get<TorrentInfo>(source);
|
const TorrentInfo &torrentInfo = std::get<TorrentInfo>(source);
|
||||||
|
|
||||||
// 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));
|
|
||||||
|
|
||||||
if (!contentName.isEmpty() && (contentName != torrentInfo.name()))
|
|
||||||
loadTorrentParams.name = contentName;
|
|
||||||
}
|
|
||||||
|
|
||||||
Q_ASSERT(addTorrentParams.filePaths.isEmpty() || (addTorrentParams.filePaths.size() == torrentInfo.filesCount()));
|
Q_ASSERT(addTorrentParams.filePaths.isEmpty() || (addTorrentParams.filePaths.size() == torrentInfo.filesCount()));
|
||||||
|
|
||||||
const TorrentContentLayout contentLayout = ((loadTorrentParams.contentLayout == TorrentContentLayout::Original)
|
const TorrentContentLayout contentLayout = ((loadTorrentParams.contentLayout == TorrentContentLayout::Original)
|
||||||
@ -2167,6 +2155,18 @@ bool Session::addTorrent_impl(const std::variant<MagnetUri, TorrentInfo> &source
|
|||||||
QStringList filePaths = (!addTorrentParams.filePaths.isEmpty() ? addTorrentParams.filePaths : torrentInfo.filePaths());
|
QStringList filePaths = (!addTorrentParams.filePaths.isEmpty() ? addTorrentParams.filePaths : torrentInfo.filePaths());
|
||||||
applyContentLayout(filePaths, contentLayout, Utils::Fs::findRootFolder(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 = 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;
|
||||||
|
}
|
||||||
|
|
||||||
if (!loadTorrentParams.hasSeedStatus)
|
if (!loadTorrentParams.hasSeedStatus)
|
||||||
{
|
{
|
||||||
const QString actualDownloadPath = useAutoTMM
|
const QString actualDownloadPath = useAutoTMM
|
||||||
|
@ -443,7 +443,7 @@ QString TorrentImpl::rootPath() const
|
|||||||
if (!hasMetadata())
|
if (!hasMetadata())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
const QString relativeRootPath = m_torrentInfo.rootFolder();
|
const QString relativeRootPath = Utils::Fs::findRootFolder(filePaths());
|
||||||
if (relativeRootPath.isEmpty())
|
if (relativeRootPath.isEmpty())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
|
@ -409,19 +409,6 @@ int TorrentInfo::fileIndex(const QString &fileName) const
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TorrentInfo::rootFolder() const
|
|
||||||
{
|
|
||||||
if (!isValid())
|
|
||||||
return {};
|
|
||||||
|
|
||||||
return Utils::Fs::findRootFolder(filePaths());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool TorrentInfo::hasRootFolder() const
|
|
||||||
{
|
|
||||||
return !rootFolder().isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
TorrentContentLayout TorrentInfo::contentLayout() const
|
TorrentContentLayout TorrentInfo::contentLayout() const
|
||||||
{
|
{
|
||||||
if (!isValid())
|
if (!isValid())
|
||||||
|
@ -92,9 +92,6 @@ namespace BitTorrent
|
|||||||
PieceRange filePieces(const QString &file) const;
|
PieceRange filePieces(const QString &file) const;
|
||||||
PieceRange filePieces(int fileIndex) const;
|
PieceRange filePieces(int fileIndex) const;
|
||||||
|
|
||||||
QString rootFolder() const;
|
|
||||||
bool hasRootFolder() const;
|
|
||||||
|
|
||||||
std::shared_ptr<lt::torrent_info> nativeInfo() const;
|
std::shared_ptr<lt::torrent_info> nativeInfo() const;
|
||||||
QVector<lt::file_index_t> nativeIndexes() const;
|
QVector<lt::file_index_t> nativeIndexes() const;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user