void ParCoordinator::UpdateParCheckProgress() { DownloadQueue::Lock(); PostInfo* pPostInfo = m_ParChecker.GetPostInfo(); if (m_ParChecker.GetFileProgress() == 0) { pPostInfo->SetProgressLabel(m_ParChecker.GetProgressLabel()); } pPostInfo->SetFileProgress(m_ParChecker.GetFileProgress()); pPostInfo->SetStageProgress(m_ParChecker.GetStageProgress()); PostInfo::EStage StageKind[] = { PostInfo::ptLoadingPars, PostInfo::ptVerifyingSources, PostInfo::ptRepairing, PostInfo::ptVerifyingRepaired }; PostInfo::EStage eStage = StageKind[m_ParChecker.GetStage()]; time_t tCurrent = time(NULL); if (pPostInfo->GetStage() != eStage) { pPostInfo->SetStage(eStage); pPostInfo->SetStageTime(tCurrent); if (pPostInfo->GetStage() == PostInfo::ptRepairing) { m_ParChecker.SetRepairTime(tCurrent); } else if (pPostInfo->GetStage() == PostInfo::ptVerifyingRepaired) { int iRepairSec = (int)(tCurrent - m_ParChecker.GetRepairTime()); pPostInfo->GetNZBInfo()->SetRepairSec(pPostInfo->GetNZBInfo()->GetRepairSec() + iRepairSec); } } bool bParCancel = false; if (!m_ParChecker.GetCancelled()) { if ((g_pOptions->GetParTimeLimit() > 0) && m_ParChecker.GetStage() == ParChecker::ptRepairing && ((g_pOptions->GetParTimeLimit() > 5 && tCurrent - pPostInfo->GetStageTime() > 5 * 60) || (g_pOptions->GetParTimeLimit() <= 5 && tCurrent - pPostInfo->GetStageTime() > 1 * 60))) { // first five (or one) minutes elapsed, now can check the estimated time int iEstimatedRepairTime = (int)((tCurrent - pPostInfo->GetStartTime()) * 1000 / (pPostInfo->GetStageProgress() > 0 ? pPostInfo->GetStageProgress() : 1)); if (iEstimatedRepairTime > g_pOptions->GetParTimeLimit() * 60) { debug("Estimated repair time %i seconds", iEstimatedRepairTime); m_ParChecker.PrintMessage(Message::mkWarning, "Cancelling par-repair for %s, estimated repair time (%i minutes) exceeds allowed repair time", m_ParChecker.GetInfoName(), iEstimatedRepairTime / 60); bParCancel = true; } } } if (bParCancel) { m_ParChecker.Cancel(); } DownloadQueue::Unlock(); CheckPauseState(pPostInfo); }
void ParCoordinator::UpdateParRenameProgress() { DownloadQueue::Lock(); PostInfo* pPostInfo = m_ParRenamer.GetPostInfo(); pPostInfo->SetProgressLabel(m_ParRenamer.GetProgressLabel()); pPostInfo->SetStageProgress(m_ParRenamer.GetStageProgress()); time_t tCurrent = time(NULL); if (pPostInfo->GetStage() != PostInfo::ptRenaming) { pPostInfo->SetStage(PostInfo::ptRenaming); pPostInfo->SetStageTime(tCurrent); } DownloadQueue::Unlock(); CheckPauseState(pPostInfo); }
void PrePostProcessor::CleanupJobs(DownloadQueue* downloadQueue) { m_activeJobs.erase(std::remove_if(m_activeJobs.begin(), m_activeJobs.end(), [processor = this, downloadQueue](NzbInfo* postJob) { PostInfo* postInfo = postJob->GetPostInfo(); if (!postInfo->GetWorking() && !(postInfo->GetPostThread() && postInfo->GetPostThread()->IsRunning())) { delete postInfo->GetPostThread(); postInfo->SetPostThread(nullptr); postInfo->SetStageTime(0); postInfo->SetStageProgress(0); postInfo->SetFileProgress(0); postInfo->SetProgressLabel(""); if (postInfo->GetStartTime() > 0) { postJob->SetPostTotalSec(postJob->GetPostTotalSec() + (int)(Util::CurrentTime() - postInfo->GetStartTime())); postInfo->SetStartTime(0); } if (postInfo->GetStage() == PostInfo::ptFinished || postInfo->GetDeleted()) { processor->JobCompleted(downloadQueue, postInfo); } else { postInfo->SetStage(PostInfo::ptQueued); } return true; } return false; }), m_activeJobs.end()); }