|
|
@ -1469,7 +1469,7 @@ void TorrentHandle::handleTorrentCheckedAlert(libtorrent::torrent_checked_alert |
|
|
|
m_hasSeedStatus = true; |
|
|
|
m_hasSeedStatus = true; |
|
|
|
|
|
|
|
|
|
|
|
adjustActualSavePath(); |
|
|
|
adjustActualSavePath(); |
|
|
|
appendExtensionsToIncompleteFiles(); |
|
|
|
manageIncompleteFiles(); |
|
|
|
|
|
|
|
|
|
|
|
if (m_pauseAfterRecheck) { |
|
|
|
if (m_pauseAfterRecheck) { |
|
|
|
m_pauseAfterRecheck = false; |
|
|
|
m_pauseAfterRecheck = false; |
|
|
@ -1491,7 +1491,7 @@ void TorrentHandle::handleTorrentFinishedAlert(libtorrent::torrent_finished_aler |
|
|
|
m_hasSeedStatus = true; |
|
|
|
m_hasSeedStatus = true; |
|
|
|
|
|
|
|
|
|
|
|
adjustActualSavePath(); |
|
|
|
adjustActualSavePath(); |
|
|
|
appendExtensionsToIncompleteFiles(); |
|
|
|
manageIncompleteFiles(); |
|
|
|
|
|
|
|
|
|
|
|
const bool recheckTorrentsOnCompletion = Preferences::instance()->recheckTorrentsOnCompletion(); |
|
|
|
const bool recheckTorrentsOnCompletion = Preferences::instance()->recheckTorrentsOnCompletion(); |
|
|
|
if (isMoveInProgress() || m_renameCount > 0) { |
|
|
|
if (isMoveInProgress() || m_renameCount > 0) { |
|
|
@ -1638,7 +1638,7 @@ void TorrentHandle::handleMetadataReceivedAlert(libt::metadata_received_alert *p |
|
|
|
qDebug("Metadata received for torrent %s.", qPrintable(name())); |
|
|
|
qDebug("Metadata received for torrent %s.", qPrintable(name())); |
|
|
|
updateStatus(); |
|
|
|
updateStatus(); |
|
|
|
if (m_session->isAppendExtensionEnabled()) |
|
|
|
if (m_session->isAppendExtensionEnabled()) |
|
|
|
appendExtensionsToIncompleteFiles(); |
|
|
|
manageIncompleteFiles(); |
|
|
|
m_session->handleTorrentMetadataReceived(this); |
|
|
|
m_session->handleTorrentMetadataReceived(this); |
|
|
|
|
|
|
|
|
|
|
|
if (isPaused()) { |
|
|
|
if (isPaused()) { |
|
|
@ -1664,10 +1664,7 @@ void TorrentHandle::handleAppendExtensionToggled() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!hasMetadata()) return; |
|
|
|
if (!hasMetadata()) return; |
|
|
|
|
|
|
|
|
|
|
|
if (m_session->isAppendExtensionEnabled()) |
|
|
|
manageIncompleteFiles(); |
|
|
|
appendExtensionsToIncompleteFiles(); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
removeExtensionsFromIncompleteFiles(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TorrentHandle::handleAlert(libtorrent::alert *a) |
|
|
|
void TorrentHandle::handleAlert(libtorrent::alert *a) |
|
|
@ -1724,12 +1721,13 @@ void TorrentHandle::handleAlert(libtorrent::alert *a) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TorrentHandle::appendExtensionsToIncompleteFiles() |
|
|
|
void TorrentHandle::manageIncompleteFiles() |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
const bool isAppendExtensionEnabled = m_session->isAppendExtensionEnabled(); |
|
|
|
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); |
|
|
|
QString name = filePath(i); |
|
|
|
if ((fileSize(i) > 0) && (fp[i] < 1)) { |
|
|
|
if (isAppendExtensionEnabled && (fileSize(i) > 0) && (fp[i] < 1)) { |
|
|
|
if (!name.endsWith(QB_EXT)) { |
|
|
|
if (!name.endsWith(QB_EXT)) { |
|
|
|
const QString newName = name + QB_EXT; |
|
|
|
const QString newName = name + QB_EXT; |
|
|
|
qDebug() << "Renaming" << name << "to" << newName; |
|
|
|
qDebug() << "Renaming" << name << "to" << newName; |
|
|
@ -1747,19 +1745,6 @@ void TorrentHandle::appendExtensionsToIncompleteFiles() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void TorrentHandle::removeExtensionsFromIncompleteFiles() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
for (int i = 0; i < filesCount(); ++i) { |
|
|
|
|
|
|
|
QString name = filePath(i); |
|
|
|
|
|
|
|
if (name.endsWith(QB_EXT)) { |
|
|
|
|
|
|
|
const QString oldName = name; |
|
|
|
|
|
|
|
name.chop(QB_EXT.size()); |
|
|
|
|
|
|
|
qDebug("Renaming %s to %s", qPrintable(oldName), qPrintable(name)); |
|
|
|
|
|
|
|
renameFile(i, name); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void TorrentHandle::adjustActualSavePath() |
|
|
|
void TorrentHandle::adjustActualSavePath() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (!isMoveInProgress()) |
|
|
|
if (!isMoveInProgress()) |
|
|
|