Fix torrent adding with existing data

This commit is contained in:
Vladimir Golovnev (Glassez) 2016-04-14 11:06:34 +03:00
parent f22aee2bff
commit 8e9b0d97ec
2 changed files with 14 additions and 14 deletions

View file

@ -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;

View file

@ -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<qreal> 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));