Browse Source

Merge pull request #8716 from sledgehammer999/move_progress

Move and recheck progress
adaptive-webui-19844
sledgehammer999 7 years ago committed by GitHub
parent
commit
8a99e29122
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 36
      src/base/bittorrent/torrenthandle.cpp
  2. 2
      src/base/bittorrent/torrenthandle.h
  3. 2
      src/gui/torrentmodel.cpp
  4. 3
      src/gui/transferlistdelegate.cpp
  5. 2
      src/webui/api/serialize/serialize_torrent.cpp
  6. 2
      src/webui/api/synccontroller.cpp
  7. 2
      src/webui/api/torrentscontroller.cpp
  8. 4
      src/webui/www/private/scripts/dynamicTable.js

36
src/base/bittorrent/torrenthandle.cpp

@ -519,15 +519,19 @@ int TorrentHandle::piecesHave() const
qreal TorrentHandle::progress() const qreal TorrentHandle::progress() const
{ {
if (!m_nativeStatus.total_wanted) if (!isChecking()) {
return 0.; if (!m_nativeStatus.total_wanted)
return 0.;
if (m_nativeStatus.total_wanted_done == m_nativeStatus.total_wanted) if (m_nativeStatus.total_wanted_done == m_nativeStatus.total_wanted)
return 1.; return 1.;
float progress = static_cast<float>(m_nativeStatus.total_wanted_done) / m_nativeStatus.total_wanted; qreal progress = static_cast<qreal>(m_nativeStatus.total_wanted_done) / m_nativeStatus.total_wanted;
Q_ASSERT((progress >= 0.f) && (progress <= 1.f)); Q_ASSERT((progress >= 0.f) && (progress <= 1.f));
return progress; return progress;
}
return m_nativeStatus.progress;
} }
QString TorrentHandle::category() const QString TorrentHandle::category() const
@ -734,7 +738,8 @@ bool TorrentHandle::isActive() const
|| m_state == TorrentState::Downloading || m_state == TorrentState::Downloading
|| m_state == TorrentState::ForcedDownloading || m_state == TorrentState::ForcedDownloading
|| m_state == TorrentState::Uploading || m_state == TorrentState::Uploading
|| m_state == TorrentState::ForcedUploading; || m_state == TorrentState::ForcedUploading
|| m_state == TorrentState::Moving;
} }
bool TorrentHandle::isInactive() const bool TorrentHandle::isInactive() const
@ -807,7 +812,10 @@ TorrentState TorrentHandle::state() const
void TorrentHandle::updateState() void TorrentHandle::updateState()
{ {
if (isPaused()) { if (isMoveInProgress()) {
m_state = TorrentState::Moving;
}
else if (isPaused()) {
if (hasMissingFiles()) if (hasMissingFiles())
m_state = TorrentState::MissingFiles; m_state = TorrentState::MissingFiles;
else if (hasError()) else if (hasError())
@ -1374,6 +1382,7 @@ void TorrentHandle::moveStorage(const QString &newPath, bool overwrite)
, (overwrite ? libt::always_replace_files : libt::dont_replace)); , (overwrite ? libt::always_replace_files : libt::dont_replace));
m_moveStorageInfo.oldPath = oldPath; m_moveStorageInfo.oldPath = oldPath;
m_moveStorageInfo.newPath = newPath; m_moveStorageInfo.newPath = newPath;
updateState();
} }
} }
@ -1440,8 +1449,8 @@ void TorrentHandle::handleStorageMovedAlert(const libtorrent::storage_moved_aler
return; return;
} }
qDebug("Torrent is successfully moved from %s to %s" LogMsg(tr("Successfully moved torrent: %1. New path: %2").arg(name(), m_moveStorageInfo.newPath));
, qUtf8Printable(m_moveStorageInfo.oldPath), qUtf8Printable(m_moveStorageInfo.newPath));
const QDir oldDir {m_moveStorageInfo.oldPath}; const QDir oldDir {m_moveStorageInfo.oldPath};
if ((oldDir == QDir(m_session->torrentTempPath(info()))) if ((oldDir == QDir(m_session->torrentTempPath(info())))
&& (oldDir != QDir(m_session->tempPath()))) { && (oldDir != QDir(m_session->tempPath()))) {
@ -1450,9 +1459,10 @@ void TorrentHandle::handleStorageMovedAlert(const libtorrent::storage_moved_aler
qDebug() << "Removing torrent temp folder:" << m_moveStorageInfo.oldPath; qDebug() << "Removing torrent temp folder:" << m_moveStorageInfo.oldPath;
Utils::Fs::smartRemoveEmptyFolderTree(m_moveStorageInfo.oldPath); Utils::Fs::smartRemoveEmptyFolderTree(m_moveStorageInfo.oldPath);
} }
updateStatus();
m_moveStorageInfo.newPath.clear(); m_moveStorageInfo.newPath.clear();
updateStatus();
if (!m_moveStorageInfo.queuedPath.isEmpty()) { if (!m_moveStorageInfo.queuedPath.isEmpty()) {
moveStorage(m_moveStorageInfo.queuedPath, m_moveStorageInfo.queuedOverwrite); moveStorage(m_moveStorageInfo.queuedPath, m_moveStorageInfo.queuedOverwrite);
m_moveStorageInfo.queuedPath.clear(); m_moveStorageInfo.queuedPath.clear();
@ -1478,6 +1488,8 @@ void TorrentHandle::handleStorageMovedFailedAlert(const libtorrent::storage_move
.arg(name(), QString::fromStdString(p->message())), Log::CRITICAL); .arg(name(), QString::fromStdString(p->message())), Log::CRITICAL);
m_moveStorageInfo.newPath.clear(); m_moveStorageInfo.newPath.clear();
updateStatus();
if (!m_moveStorageInfo.queuedPath.isEmpty()) { if (!m_moveStorageInfo.queuedPath.isEmpty()) {
moveStorage(m_moveStorageInfo.queuedPath, m_moveStorageInfo.queuedOverwrite); moveStorage(m_moveStorageInfo.queuedPath, m_moveStorageInfo.queuedOverwrite);
m_moveStorageInfo.queuedPath.clear(); m_moveStorageInfo.queuedPath.clear();

2
src/base/bittorrent/torrenthandle.h

@ -149,6 +149,8 @@ namespace BitTorrent
PausedDownloading, PausedDownloading,
PausedUploading, PausedUploading,
Moving,
MissingFiles, MissingFiles,
Error Error
}; };

2
src/gui/torrentmodel.cpp

@ -349,6 +349,7 @@ QIcon getIconByState(BitTorrent::TorrentState state)
case BitTorrent::TorrentState::QueuedForChecking: case BitTorrent::TorrentState::QueuedForChecking:
#endif #endif
case BitTorrent::TorrentState::CheckingResumeData: case BitTorrent::TorrentState::CheckingResumeData:
case BitTorrent::TorrentState::Moving:
return getCheckingIcon(); return getCheckingIcon();
case BitTorrent::TorrentState::Unknown: case BitTorrent::TorrentState::Unknown:
case BitTorrent::TorrentState::MissingFiles: case BitTorrent::TorrentState::MissingFiles:
@ -404,6 +405,7 @@ QColor getColorByState(BitTorrent::TorrentState state)
case BitTorrent::TorrentState::QueuedForChecking: case BitTorrent::TorrentState::QueuedForChecking:
#endif #endif
case BitTorrent::TorrentState::CheckingResumeData: case BitTorrent::TorrentState::CheckingResumeData:
case BitTorrent::TorrentState::Moving:
if (!dark) if (!dark)
return QColor(0, 128, 128); // Teal return QColor(0, 128, 128); // Teal
else else

3
src/gui/transferlistdelegate.cpp

@ -272,6 +272,9 @@ QString TransferListDelegate::getStatusString(const BitTorrent::TorrentState sta
case BitTorrent::TorrentState::PausedUploading: case BitTorrent::TorrentState::PausedUploading:
str = tr("Completed"); str = tr("Completed");
break; break;
case BitTorrent::TorrentState::Moving:
str = tr("Moving", "Torrent local data are being moved/relocated");
break;
case BitTorrent::TorrentState::MissingFiles: case BitTorrent::TorrentState::MissingFiles:
str = tr("Missing Files"); str = tr("Missing Files");
break; break;

2
src/webui/api/serialize/serialize_torrent.cpp

@ -76,6 +76,8 @@ namespace
#endif #endif
case BitTorrent::TorrentState::CheckingResumeData: case BitTorrent::TorrentState::CheckingResumeData:
return QLatin1String("checkingResumeData"); return QLatin1String("checkingResumeData");
case BitTorrent::TorrentState::Moving:
return QLatin1String("moving");
default: default:
return QLatin1String("unknown"); return QLatin1String("unknown");
} }

2
src/webui/api/synccontroller.cpp

@ -327,7 +327,7 @@ namespace
// Each value of the 'torrents' dictionary contains map. The map can contain following keys: // Each value of the 'torrents' dictionary contains map. The map can contain following keys:
// - "name": Torrent name // - "name": Torrent name
// - "size": Torrent size // - "size": Torrent size
// - "progress: Torrent progress // - "progress": Torrent progress
// - "dlspeed": Torrent download speed // - "dlspeed": Torrent download speed
// - "upspeed": Torrent upload speed // - "upspeed": Torrent upload speed
// - "priority": Torrent priority (-1 if queuing is disabled) // - "priority": Torrent priority (-1 if queuing is disabled)

2
src/webui/api/torrentscontroller.cpp

@ -132,7 +132,7 @@ namespace
// - "hash": Torrent hash // - "hash": Torrent hash
// - "name": Torrent name // - "name": Torrent name
// - "size": Torrent size // - "size": Torrent size
// - "progress: Torrent progress // - "progress": Torrent progress
// - "dlspeed": Torrent download speed // - "dlspeed": Torrent download speed
// - "upspeed": Torrent upload speed // - "upspeed": Torrent upload speed
// - "priority": Torrent priority (-1 if queuing is disabled) // - "priority": Torrent priority (-1 if queuing is disabled)

4
src/webui/www/private/scripts/dynamicTable.js

@ -814,6 +814,7 @@ var TorrentsTable = new Class({
case "checkingUP": case "checkingUP":
case "queuedForChecking": case "queuedForChecking":
case "checkingResumeData": case "checkingResumeData":
case "moving":
state = "checking"; state = "checking";
break; break;
case "unknown": case "unknown":
@ -887,6 +888,9 @@ var TorrentsTable = new Class({
case "pausedUP": case "pausedUP":
status = "Completed"; status = "Completed";
break; break;
case "moving":
status = "Moving";
break;
case "missingFiles": case "missingFiles":
status = "Missing Files"; status = "Missing Files";
break; break;

Loading…
Cancel
Save