From 25feee236633b3e048709ca183f548239af39457 Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Sun, 1 Nov 2015 09:22:18 +0300 Subject: [PATCH] Fix 'Append label to save path'. Closes #4031. --- src/core/bittorrent/session.cpp | 24 ++++++++++++------------ src/core/bittorrent/session.h | 2 +- src/core/bittorrent/torrenthandle.cpp | 3 --- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/core/bittorrent/session.cpp b/src/core/bittorrent/session.cpp index 9a237666c..3b15437fd 100644 --- a/src/core/bittorrent/session.cpp +++ b/src/core/bittorrent/session.cpp @@ -1026,7 +1026,7 @@ bool Session::addTorrent(const TorrentInfo &torrentInfo, const AddTorrentParams } // Add a torrent to the BitTorrent session -bool Session::addTorrent_impl(const AddTorrentData &addData, const MagnetUri &magnetUri, +bool Session::addTorrent_impl(AddTorrentData addData, const MagnetUri &magnetUri, const TorrentInfo &torrentInfo, const QByteArray &fastresumeData) { libt::add_torrent_params p; @@ -1098,21 +1098,21 @@ bool Session::addTorrent_impl(const AddTorrentData &addData, const MagnetUri &ma p.max_connections = pref->getMaxConnecsPerTorrent(); p.max_uploads = pref->getMaxUploadsPerTorrent(); + if (addData.savePath.isEmpty()) { + addData.savePath = m_defaultSavePath; + if (m_appendLabelToSavePath && !addData.label.isEmpty()) + addData.savePath += QString("%1/").arg(addData.label); + } + else if (!addData.savePath.endsWith("/")) { + addData.savePath += "/"; + } + QString savePath; // Set actual save path (e.g. temporary folder) - if (isTempPathEnabled() && !addData.disableTempPath && !addData.hasSeedStatus) { + if (isTempPathEnabled() && !addData.disableTempPath && !addData.hasSeedStatus) savePath = m_tempPath; - } - else { + else savePath = addData.savePath; - if (savePath.isEmpty()) { - savePath = m_defaultSavePath; - if (m_appendLabelToSavePath && !addData.label.isEmpty()) - savePath += QString("%1/").arg(addData.label); - } - else if (!savePath.endsWith("/")) - savePath += "/"; - } p.save_path = Utils::String::toStdString(Utils::Fs::toNativePath(savePath)); // Check if save path exists, creating it otherwise diff --git a/src/core/bittorrent/session.h b/src/core/bittorrent/session.h index b0d046a80..9b1280062 100644 --- a/src/core/bittorrent/session.h +++ b/src/core/bittorrent/session.h @@ -288,7 +288,7 @@ namespace BitTorrent void setAppendExtension(bool append); void startUpTorrents(); - bool addTorrent_impl(const AddTorrentData &addData, const MagnetUri &magnetUri, + bool addTorrent_impl(AddTorrentData addData, const MagnetUri &magnetUri, const TorrentInfo &torrentInfo = TorrentInfo(), const QByteArray &fastresumeData = QByteArray()); diff --git a/src/core/bittorrent/torrenthandle.cpp b/src/core/bittorrent/torrenthandle.cpp index 3cc2d8ee4..a0c95d00d 100644 --- a/src/core/bittorrent/torrenthandle.cpp +++ b/src/core/bittorrent/torrenthandle.cpp @@ -202,9 +202,6 @@ TorrentHandle::TorrentHandle(Session *session, const libtorrent::torrent_handle , m_pauseAfterRecheck(false) , m_needSaveResumeData(false) { - if (m_savePath.isEmpty()) - m_savePath = Utils::Fs::toNativePath(m_session->defaultSavePath()); - initialize(); if (!data.resumed) {