Browse Source

Fix torrent adding with existing data

adaptive-webui-19844
Vladimir Golovnev (Glassez) 9 years ago
parent
commit
8e9b0d97ec
  1. 5
      src/base/bittorrent/session.cpp
  2. 23
      src/base/bittorrent/torrenthandle.cpp

5
src/base/bittorrent/session.cpp

@ -1331,10 +1331,7 @@ bool Session::addTorrent_impl(AddTorrentData addData, const MagnetUri &magnetUri
p.max_uploads = pref->getMaxUploadsPerTorrent(); p.max_uploads = pref->getMaxUploadsPerTorrent();
QString savePath; QString savePath;
// Set actual save path (e.g. temporary folder) if (addData.savePath.isEmpty()) // using Advanced mode
if (isTempPathEnabled() && !addData.disableTempPath && !addData.hasSeedStatus)
savePath = m_tempPath;
else if (addData.savePath.isEmpty()) // using Advanced mode
savePath = categorySavePath(addData.category); savePath = categorySavePath(addData.category);
else // using Simple mode else // using Simple mode
savePath = addData.savePath; savePath = addData.savePath;

23
src/base/bittorrent/torrenthandle.cpp

@ -215,15 +215,9 @@ TorrentHandle::TorrentHandle(Session *session, const libtorrent::torrent_handle
updateStatus(); updateStatus();
m_hash = InfoHash(m_nativeStatus.info_hash); m_hash = InfoHash(m_nativeStatus.info_hash);
adjustActualSavePath();
if (!data.resumed) { if (!data.resumed)
setSequentialDownload(data.sequential); setSequentialDownload(data.sequential);
if (hasMetadata()) {
if (m_session->isAppendExtensionEnabled())
appendExtensionsToIncompleteFiles();
}
}
} }
TorrentHandle::~TorrentHandle() {} TorrentHandle::~TorrentHandle() {}
@ -1475,6 +1469,7 @@ void TorrentHandle::handleTorrentCheckedAlert(libtorrent::torrent_checked_alert
m_hasSeedStatus = true; m_hasSeedStatus = true;
adjustActualSavePath(); adjustActualSavePath();
appendExtensionsToIncompleteFiles();
if (m_pauseAfterRecheck) { if (m_pauseAfterRecheck) {
m_pauseAfterRecheck = false; m_pauseAfterRecheck = false;
@ -1727,14 +1722,22 @@ void TorrentHandle::appendExtensionsToIncompleteFiles()
{ {
QVector<qreal> fp = filesProgress(); QVector<qreal> fp = filesProgress();
for (int i = 0; i < filesCount(); ++i) { for (int i = 0; i < filesCount(); ++i) {
QString name = filePath(i);
if ((fileSize(i) > 0) && (fp[i] < 1)) { if ((fileSize(i) > 0) && (fp[i] < 1)) {
const QString name = filePath(i);
if (!name.endsWith(QB_EXT)) { if (!name.endsWith(QB_EXT)) {
const QString newName = name + 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); 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 { else {
// Moving all downloading torrents to temporary save path // Moving all downloading torrents to temporary save path
path = m_session->tempPath(); 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)); moveStorage(Utils::Fs::toNativePath(path));

Loading…
Cancel
Save