From 8e9b0d97ec52888f087ff6cfcc0c03f3ca5bf739 Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Thu, 14 Apr 2016 11:06:34 +0300 Subject: [PATCH] Fix torrent adding with existing data --- src/base/bittorrent/session.cpp | 5 +---- src/base/bittorrent/torrenthandle.cpp | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/base/bittorrent/session.cpp b/src/base/bittorrent/session.cpp index e781b15a6..d0fdd4c44 100644 --- a/src/base/bittorrent/session.cpp +++ b/src/base/bittorrent/session.cpp @@ -1331,10 +1331,7 @@ bool Session::addTorrent_impl(AddTorrentData addData, const MagnetUri &magnetUri p.max_uploads = pref->getMaxUploadsPerTorrent(); QString savePath; - // Set actual save path (e.g. temporary folder) - if (isTempPathEnabled() && !addData.disableTempPath && !addData.hasSeedStatus) - savePath = m_tempPath; - else if (addData.savePath.isEmpty()) // using Advanced mode + if (addData.savePath.isEmpty()) // using Advanced mode savePath = categorySavePath(addData.category); else // using Simple mode savePath = addData.savePath; diff --git a/src/base/bittorrent/torrenthandle.cpp b/src/base/bittorrent/torrenthandle.cpp index 7fd86e9cc..8aa4ce317 100644 --- a/src/base/bittorrent/torrenthandle.cpp +++ b/src/base/bittorrent/torrenthandle.cpp @@ -215,15 +215,9 @@ TorrentHandle::TorrentHandle(Session *session, const libtorrent::torrent_handle updateStatus(); m_hash = InfoHash(m_nativeStatus.info_hash); - adjustActualSavePath(); - if (!data.resumed) { + if (!data.resumed) setSequentialDownload(data.sequential); - if (hasMetadata()) { - if (m_session->isAppendExtensionEnabled()) - appendExtensionsToIncompleteFiles(); - } - } } TorrentHandle::~TorrentHandle() {} @@ -1475,6 +1469,7 @@ void TorrentHandle::handleTorrentCheckedAlert(libtorrent::torrent_checked_alert m_hasSeedStatus = true; adjustActualSavePath(); + appendExtensionsToIncompleteFiles(); if (m_pauseAfterRecheck) { m_pauseAfterRecheck = false; @@ -1727,14 +1722,22 @@ void TorrentHandle::appendExtensionsToIncompleteFiles() { QVector fp = filesProgress(); for (int i = 0; i < filesCount(); ++i) { + QString name = filePath(i); if ((fileSize(i) > 0) && (fp[i] < 1)) { - const QString name = filePath(i); if (!name.endsWith(QB_EXT)) { const QString newName = name + QB_EXT; - qDebug("Renaming %s to %s", qPrintable(name), qPrintable(newName)); + qDebug() << "Renaming" << name << "to" << newName; renameFile(i, newName); } } + else { + if (name.endsWith(QB_EXT)) { + const QString oldName = name; + name.chop(QString(QB_EXT).size()); + qDebug() << "Renaming" << oldName << "to" << name; + renameFile(i, name); + } + } } } @@ -1770,7 +1773,7 @@ void TorrentHandle::adjustActualSavePath_impl() else { // Moving all downloading torrents to temporary save path path = m_session->tempPath(); - qDebug("Moving torrent to its temp save path: %s", qPrintable(path)); + qDebug() << "Moving torrent to its temp save path:" << path; } moveStorage(Utils::Fs::toNativePath(path));