|
|
@ -2268,7 +2268,7 @@ bool SessionImpl::deleteTorrent(const TorrentID &id, const DeleteOption deleteOp |
|
|
|
{ |
|
|
|
{ |
|
|
|
// Delete "move storage job" for the deleted torrent
|
|
|
|
// Delete "move storage job" for the deleted torrent
|
|
|
|
// (note: we shouldn't delete active job)
|
|
|
|
// (note: we shouldn't delete active job)
|
|
|
|
const auto iter = std::find_if(m_moveStorageQueue.begin() + 1, m_moveStorageQueue.end() |
|
|
|
const auto iter = std::find_if((m_moveStorageQueue.begin() + 1), m_moveStorageQueue.end() |
|
|
|
, [torrent](const MoveStorageJob &job) |
|
|
|
, [torrent](const MoveStorageJob &job) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return job.torrentHandle == torrent->nativeHandle(); |
|
|
|
return job.torrentHandle == torrent->nativeHandle(); |
|
|
@ -2903,37 +2903,49 @@ void SessionImpl::saveResumeData() |
|
|
|
++m_numResumeData; |
|
|
|
++m_numResumeData; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// clear queued storage move jobs except the current ongoing one
|
|
|
|
|
|
|
|
if (m_moveStorageQueue.size() > 1) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) |
|
|
|
|
|
|
|
m_moveStorageQueue = m_moveStorageQueue.mid(0, 1); |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
m_moveStorageQueue.resize(1); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QElapsedTimer timer; |
|
|
|
QElapsedTimer timer; |
|
|
|
timer.start(); |
|
|
|
timer.start(); |
|
|
|
|
|
|
|
|
|
|
|
while (m_numResumeData > 0) |
|
|
|
while ((m_numResumeData > 0) || !m_moveStorageQueue.isEmpty()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const lt::seconds waitTime {5}; |
|
|
|
const lt::seconds waitTime {5}; |
|
|
|
const lt::seconds expireTime {30}; |
|
|
|
const lt::seconds expireTime {30}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// only terminate when no storage is moving
|
|
|
|
|
|
|
|
if (timer.hasExpired(lt::total_milliseconds(expireTime)) && m_moveStorageQueue.isEmpty()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
LogMsg(tr("Aborted saving resume data. Number of outstanding torrents: %1").arg(QString::number(m_numResumeData)) |
|
|
|
|
|
|
|
, Log::CRITICAL); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const std::vector<lt::alert *> alerts = getPendingAlerts(waitTime); |
|
|
|
const std::vector<lt::alert *> alerts = getPendingAlerts(waitTime); |
|
|
|
|
|
|
|
|
|
|
|
bool hasWantedAlert = false; |
|
|
|
bool hasWantedAlert = false; |
|
|
|
for (const lt::alert *a : alerts) |
|
|
|
for (const lt::alert *a : alerts) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (const int alertType = a->type(); |
|
|
|
if (const int alertType = a->type(); |
|
|
|
(alertType == lt::save_resume_data_alert::alert_type) |
|
|
|
(alertType == lt::save_resume_data_alert::alert_type) || (alertType == lt::save_resume_data_failed_alert::alert_type) |
|
|
|
|| (alertType == lt::save_resume_data_failed_alert::alert_type)) |
|
|
|
|| (alertType == lt::storage_moved_alert::alert_type) || (alertType == lt::storage_moved_failed_alert::alert_type)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
hasWantedAlert = true; |
|
|
|
hasWantedAlert = true; |
|
|
|
handleAlert(a); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
handleAlert(a); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (hasWantedAlert) |
|
|
|
if (hasWantedAlert) |
|
|
|
{ |
|
|
|
|
|
|
|
timer.start(); |
|
|
|
timer.start(); |
|
|
|
} |
|
|
|
|
|
|
|
else if (timer.hasExpired(lt::total_milliseconds(expireTime))) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
LogMsg(tr("Aborted saving resume data. Number of outstanding torrents: %1").arg(QString::number(m_numResumeData)) |
|
|
|
|
|
|
|
, Log::CRITICAL); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -4675,7 +4687,7 @@ bool SessionImpl::addMoveTorrentStorageJob(TorrentImpl *torrent, const Path &new |
|
|
|
|
|
|
|
|
|
|
|
if (m_moveStorageQueue.size() > 1) |
|
|
|
if (m_moveStorageQueue.size() > 1) |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto iter = std::find_if(m_moveStorageQueue.begin() + 1, m_moveStorageQueue.end() |
|
|
|
auto iter = std::find_if((m_moveStorageQueue.begin() + 1), m_moveStorageQueue.end() |
|
|
|
, [&torrentHandle](const MoveStorageJob &job) |
|
|
|
, [&torrentHandle](const MoveStorageJob &job) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return job.torrentHandle == torrentHandle; |
|
|
|
return job.torrentHandle == torrentHandle; |
|
|
|