void BundleQueue::removeBundleItem(QueueItemPtr& aQI, bool aDownloadFinished) noexcept { dcassert(aQI->getBundle()); aQI->getBundle()->removeQueue(aQI, aDownloadFinished); if (!aQI->getBundle()->isFileBundle()) { forEachPath(aQI->getBundle(), aQI->getTarget(), [&](PathInfo& aInfo) { if (aQI->isDownloaded()) { aInfo.finishedFiles--; } else { aInfo.queuedFiles--; } if (!aDownloadFinished) { aInfo.size -= aQI->getSize(); } #ifdef _DEBUG if (aInfo.queuedFiles == 0 && aInfo.finishedFiles == 0) { dcassert(aInfo.size == 0); } dcassert(aInfo.size >= 0 && aInfo.finishedFiles >= 0 && aInfo.queuedFiles >= 0); #endif }); } if (aDownloadFinished || !aQI->isDownloaded()) { queueSize -= aQI->getSize(); dcassert(queueSize >= 0); } }
void BundleQueue::addBundleItem(QueueItemPtr& aQI, BundlePtr& aBundle) noexcept { dcassert(!aQI->getBundle()); aBundle->addQueue(aQI); aQI->setBundle(aBundle); if (!aBundle->isFileBundle()) { forEachPath(aBundle, aQI->getTarget(), [&](PathInfo& aInfo) { if (aQI->isDownloaded()) { aInfo.finishedFiles++; } else { aInfo.queuedFiles++; } aInfo.size += aQI->getSize(); }); } if (!aQI->isDownloaded()) { queueSize += aQI->getSize(); } }