Browse Source

Fix .!qB extension is added when disabled

adaptive-webui-19844
Vladimir Golovnev (Glassez) 9 years ago
parent
commit
56287173b1
  1. 29
      src/base/bittorrent/torrenthandle.cpp
  2. 3
      src/base/bittorrent/torrenthandle.h

29
src/base/bittorrent/torrenthandle.cpp

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

3
src/base/bittorrent/torrenthandle.h

@ -388,8 +388,7 @@ namespace BitTorrent @@ -388,8 +388,7 @@ namespace BitTorrent
void adjustActualSavePath_impl();
void move_impl(QString path);
void moveStorage(const QString &newPath);
void appendExtensionsToIncompleteFiles();
void removeExtensionsFromIncompleteFiles();
void manageIncompleteFiles();
bool addTracker(const TrackerEntry &tracker);
bool addUrlSeed(const QUrl &urlSeed);
bool removeUrlSeed(const QUrl &urlSeed);

Loading…
Cancel
Save